@@ -23,33 +23,13 @@ import childProcess from 'child_process';
2323export default ( context ) => {
2424 const projectRoot = context . opts . projectRoot ;
2525 const glob = context . requireCordovaModule ( 'glob' ) ;
26- const cordovaUtil = context . requireCordovaModule ( 'cordova-lib/src/cordova/util' ) ;
27- const Q = context . requireCordovaModule ( 'q' ) ;
28- const getPlatformVersionsFromFileSystem = ( projectRoot ) => {
29- var platformsOnFs = cordovaUtil . listPlatforms ( projectRoot ) ;
30- var platformVersions = platformsOnFs . map ( function ( platform ) {
31- var script = path . join ( projectRoot , 'platforms' , platform , 'cordova' , 'version' ) ;
32- return Q . ninvoke ( childProcess , 'exec' , script , { } ) . then ( function ( result ) {
33- var version = result [ 0 ] ;
34-
35- // clean the version we get back from the script
36- // This is necessary because the version script uses console.log to pass back
37- // the version. Using console.log ends up adding additional line breaks/newlines to the value returned.
38- // ToDO: version scripts should be refactored to not use console.log()
39- var versionCleaned = version . replace ( / \r ? \n | \r / g, '' ) ;
40- return { platform : platform , version : versionCleaned } ;
41- } ) ;
42- } ) ;
43-
44- return Q . all ( platformVersions ) ;
45- } ;
4626
4727 // This script has to be executed depending on the command line arguments, not
4828 // on the hook execution cycle.
4929 if ( ( context . hook === 'after_platform_add' && context . cmdLine . includes ( 'platform add' ) ) ||
5030 ( context . hook === 'after_prepare' && context . cmdLine . includes ( 'prepare' ) ) ||
5131 ( context . hook === 'after_plugin_add' && context . cmdLine . includes ( 'plugin add' ) ) ) {
52- getPlatformVersionsFromFileSystem ( projectRoot ) . then ( ( platformVersions ) => {
32+ getPlatformVersionsFromFileSystem ( context , projectRoot ) . then ( ( platformVersions ) => {
5333 const IOS_MIN_DEPLOYMENT_TARGET = '7.0' ;
5434 const platformPath = path . join ( projectRoot , 'platforms' , 'ios' ) ;
5535 const config = getConfigParser ( context , path . join ( projectRoot , 'config.xml' ) ) ;
@@ -210,3 +190,19 @@ const getBridgingHeaderPath = (context, projectPath, iosPlatformVersion) => {
210190
211191 return bridgingHeaderPath ;
212192} ;
193+
194+ const getPlatformVersionsFromFileSystem = ( context , projectRoot ) => {
195+ const cordovaUtil = context . requireCordovaModule ( 'cordova-lib/src/cordova/util' ) ;
196+ const Q = context . requireCordovaModule ( 'q' ) ;
197+ const platformsOnFs = cordovaUtil . listPlatforms ( projectRoot ) ;
198+ const platformVersions = platformsOnFs . map ( ( platform ) => {
199+ const script = path . join ( projectRoot , 'platforms' , platform , 'cordova' , 'version' ) ;
200+ return Q . ninvoke ( childProcess , 'exec' , script , { } ) . then ( ( result ) => {
201+ const version = result [ 0 ] ;
202+ const versionCleaned = version . replace ( / \r ? \n | \r / g, '' ) ;
203+ return { platform : platform , version : versionCleaned } ;
204+ } ) ;
205+ } ) ;
206+
207+ return Q . all ( platformVersions ) ;
208+ } ;
0 commit comments