@@ -23,33 +23,13 @@ import childProcess from 'child_process';
23
23
export default ( context ) => {
24
24
const projectRoot = context . opts . projectRoot ;
25
25
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
- } ;
46
26
47
27
// This script has to be executed depending on the command line arguments, not
48
28
// on the hook execution cycle.
49
29
if ( ( context . hook === 'after_platform_add' && context . cmdLine . includes ( 'platform add' ) ) ||
50
30
( context . hook === 'after_prepare' && context . cmdLine . includes ( 'prepare' ) ) ||
51
31
( context . hook === 'after_plugin_add' && context . cmdLine . includes ( 'plugin add' ) ) ) {
52
- getPlatformVersionsFromFileSystem ( projectRoot ) . then ( ( platformVersions ) => {
32
+ getPlatformVersionsFromFileSystem ( context , projectRoot ) . then ( ( platformVersions ) => {
53
33
const IOS_MIN_DEPLOYMENT_TARGET = '7.0' ;
54
34
const platformPath = path . join ( projectRoot , 'platforms' , 'ios' ) ;
55
35
const config = getConfigParser ( context , path . join ( projectRoot , 'config.xml' ) ) ;
@@ -210,3 +190,19 @@ const getBridgingHeaderPath = (context, projectPath, iosPlatformVersion) => {
210
190
211
191
return bridgingHeaderPath ;
212
192
} ;
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