17
17
'use strict' ;
18
18
const fs = require ( 'fs-extra' ) ;
19
19
const path = require ( 'path' ) ;
20
- const shell = require ( 'shelljs' ) ;
21
20
const util = require ( 'util' ) ;
22
21
const events = require ( 'cordova-common' ) . events ;
23
22
const CordovaError = require ( 'cordova-common' ) . CordovaError ;
@@ -77,7 +76,7 @@ const handlers = {
77
76
const destFile = path . resolve ( project . resources_dir , target ) ;
78
77
79
78
project . xcode . removeResourceFile ( path . join ( 'Resources' , target ) ) ;
80
- shell . rm ( '-rf' , destFile ) ;
79
+ fs . removeSync ( destFile ) ;
81
80
}
82
81
} ,
83
82
framework : { // CB-5238 custom frameworks only
@@ -149,7 +148,7 @@ const handlers = {
149
148
if ( pbxFile ) {
150
149
project . xcode . removeFromPbxEmbedFrameworksBuildPhase ( pbxFile ) ;
151
150
}
152
- shell . rm ( '-rf' , targetDir ) ;
151
+ fs . removeSync ( targetDir ) ;
153
152
}
154
153
} ,
155
154
'lib-file' : {
@@ -201,11 +200,11 @@ const handlers = {
201
200
scriptContent = `cordova.define("${ moduleName } ", function(require, exports, module) {\n${ scriptContent } \n});\n` ;
202
201
203
202
const moduleDestination = path . resolve ( project . www , 'plugins' , plugin . id , obj . src ) ;
204
- shell . mkdir ( '-p' , path . dirname ( moduleDestination ) ) ;
203
+ fs . ensureDirSync ( path . dirname ( moduleDestination ) ) ;
205
204
fs . writeFileSync ( moduleDestination , scriptContent , 'utf-8' ) ;
206
205
if ( options && options . usePlatformWww ) {
207
206
const platformWwwDestination = path . resolve ( project . platformWww , 'plugins' , plugin . id , obj . src ) ;
208
- shell . mkdir ( '-p' , path . dirname ( platformWwwDestination ) ) ;
207
+ fs . ensureDirSync ( path . dirname ( platformWwwDestination ) ) ;
209
208
fs . writeFileSync ( platformWwwDestination , scriptContent , 'utf-8' ) ;
210
209
}
211
210
} ,
@@ -287,7 +286,7 @@ function uninstallHelper (type, obj, project_dir, plugin_id, options, project) {
287
286
project_ref = `Plugins/${ fixPathSep ( path . relative ( project . plugins_dir , destFile ) ) } ` ;
288
287
}
289
288
290
- shell . rm ( '-rf' , targetDir ) ;
289
+ fs . removeSync ( targetDir ) ;
291
290
292
291
if ( type === 'header-file' ) {
293
292
project . xcode . removeHeaderFile ( project_ref ) ;
@@ -319,15 +318,12 @@ function copyFile (plugin_dir, src, project_dir, dest, link) {
319
318
// check that dest path is located in project directory
320
319
if ( dest . indexOf ( project_dir ) !== 0 ) { throw new CordovaError ( `Destination "${ dest } " for source file "${ src } " is located outside the project` ) ; }
321
320
322
- shell . mkdir ( '-p' , path . dirname ( dest ) ) ;
321
+ fs . ensureDirSync ( path . dirname ( dest ) ) ;
323
322
324
323
if ( link ) {
325
324
linkFileOrDirTree ( src , dest ) ;
326
- } else if ( fs . statSync ( src ) . isDirectory ( ) ) {
327
- // XXX shelljs decides to create a directory when -R|-r is used which sucks. http://goo.gl/nbsjq
328
- shell . cp ( '-Rf' , path . join ( src , '/*' ) , dest ) ;
329
325
} else {
330
- shell . cp ( '-f' , src , dest ) ;
326
+ fs . copySync ( src , dest ) ;
331
327
}
332
328
}
333
329
@@ -341,11 +337,11 @@ function copyNewFile (plugin_dir, src, project_dir, dest, link) {
341
337
342
338
function linkFileOrDirTree ( src , dest ) {
343
339
if ( fs . existsSync ( dest ) ) {
344
- shell . rm ( '-Rf' , dest ) ;
340
+ fs . removeSync ( dest ) ;
345
341
}
346
342
347
343
if ( fs . statSync ( src ) . isDirectory ( ) ) {
348
- shell . mkdir ( '-p' , dest ) ;
344
+ fs . ensureDirSync ( dest ) ;
349
345
fs . readdirSync ( src ) . forEach ( entry => {
350
346
linkFileOrDirTree ( path . join ( src , entry ) , path . join ( dest , entry ) ) ;
351
347
} ) ;
@@ -357,12 +353,12 @@ function linkFileOrDirTree (src, dest) {
357
353
// checks if file exists and then deletes. Error if doesn't exist
358
354
function removeFile ( project_dir , src ) {
359
355
const file = path . resolve ( project_dir , src ) ;
360
- shell . rm ( '-Rf' , file ) ;
356
+ fs . removeSync ( file ) ;
361
357
}
362
358
363
359
// deletes file/directory without checking
364
360
function removeFileF ( file ) {
365
- shell . rm ( '-Rf' , file ) ;
361
+ fs . removeSync ( file ) ;
366
362
}
367
363
368
364
function removeFileAndParents ( baseDir , destFile , stopper ) {
0 commit comments