@@ -21,7 +21,6 @@ const os = require('os');
2121const fs = require ( 'fs-extra' ) ;
2222const path = require ( 'path' ) ;
2323const rewire = require ( 'rewire' ) ;
24- const shell = require ( 'shelljs' ) ;
2524const EventEmitter = require ( 'events' ) ;
2625
2726const PluginInfo = require ( 'cordova-common' ) . PluginInfo ;
@@ -32,7 +31,7 @@ const pluginHandlers = rewire('../../../../bin/templates/scripts/cordova/lib/plu
3231const temp = path . join ( os . tmpdir ( ) , 'plugman' ) ;
3332
3433const FIXTURES = path . join ( __dirname , '../fixtures' ) ;
35- const iosProject = path . join ( FIXTURES , 'ios-config-xml' , '*' ) ;
34+ const iosProject = path . join ( FIXTURES , 'ios-config-xml' ) ;
3635const faultyplugin = path . join ( FIXTURES , 'org.test.plugins.faultyplugin' ) ;
3736const dummyplugin = path . join ( FIXTURES , 'org.test.plugins.dummyplugin' ) ;
3837const weblessplugin = path . join ( FIXTURES , 'org.test.plugins.weblessplugin' ) ;
@@ -68,7 +67,7 @@ describe('ios plugin handler', () => {
6867 let dummyProject ;
6968
7069 beforeEach ( ( ) => {
71- shell . cp ( '-rf' , iosProject , temp ) ;
70+ fs . copySync ( iosProject , temp ) ;
7271 projectFile . purgeProjectFileCache ( temp ) ;
7372
7473 dummyProject = projectFile . parse ( {
@@ -118,15 +117,15 @@ describe('ios plugin handler', () => {
118117 } ) ;
119118 it ( 'Test 005 : should cp the file to the right target location when element has no target-dir' , ( ) => {
120119 const source = copyArray ( valid_source ) . filter ( s => s . targetDir === undefined ) ;
121- const spy = spyOn ( shell , 'cp ' ) ;
120+ spyOn ( fs , 'copySync ' ) ;
122121 install ( source [ 0 ] , dummyPluginInfo , dummyProject ) ;
123- expect ( spy ) . toHaveBeenCalledWith ( '-f' , path . join ( dummyplugin , 'src' , 'ios' , 'DummyPluginCommand.m' ) , path . join ( temp , 'SampleApp' , 'Plugins' , dummy_id , 'DummyPluginCommand.m' ) ) ;
122+ expect ( fs . copySync ) . toHaveBeenCalledWith ( path . join ( dummyplugin , 'src' , 'ios' , 'DummyPluginCommand.m' ) , path . join ( temp , 'SampleApp' , 'Plugins' , dummy_id , 'DummyPluginCommand.m' ) ) ;
124123 } ) ;
125124 it ( 'Test 006 : should cp the file to the right target location when element has a target-dir' , ( ) => {
126125 const source = copyArray ( valid_source ) . filter ( s => s . targetDir !== undefined ) ;
127- const spy = spyOn ( shell , 'cp ' ) ;
126+ spyOn ( fs , 'copySync ' ) ;
128127 install ( source [ 0 ] , dummyPluginInfo , dummyProject ) ;
129- expect ( spy ) . toHaveBeenCalledWith ( '-f' , path . join ( dummyplugin , 'src' , 'ios' , 'TargetDirTest.m' ) , path . join ( temp , 'SampleApp' , 'Plugins' , dummy_id , 'targetDir' , 'TargetDirTest.m' ) ) ;
128+ expect ( fs . copySync ) . toHaveBeenCalledWith ( path . join ( dummyplugin , 'src' , 'ios' , 'TargetDirTest.m' ) , path . join ( temp , 'SampleApp' , 'Plugins' , dummy_id , 'targetDir' , 'TargetDirTest.m' ) ) ;
130129 } ) ;
131130 it ( 'Test 007 : should call into xcodeproj\'s addFramework appropriately when element has framework=true set' , ( ) => {
132131 const source = copyArray ( valid_source ) . filter ( s => s . framework ) ;
@@ -173,15 +172,15 @@ describe('ios plugin handler', () => {
173172 } ) ;
174173 it ( 'Test 012 : should cp the file to the right target location when element has no target-dir' , ( ) => {
175174 const headers = copyArray ( valid_headers ) . filter ( s => s . targetDir === undefined ) ;
176- const spy = spyOn ( shell , 'cp ' ) ;
175+ spyOn ( fs , 'copySync ' ) ;
177176 install ( headers [ 0 ] , dummyPluginInfo , dummyProject ) ;
178- expect ( spy ) . toHaveBeenCalledWith ( '-f' , path . join ( dummyplugin , 'src' , 'ios' , 'DummyPluginCommand.h' ) , path . join ( temp , 'SampleApp' , 'Plugins' , dummy_id , 'DummyPluginCommand.h' ) ) ;
177+ expect ( fs . copySync ) . toHaveBeenCalledWith ( path . join ( dummyplugin , 'src' , 'ios' , 'DummyPluginCommand.h' ) , path . join ( temp , 'SampleApp' , 'Plugins' , dummy_id , 'DummyPluginCommand.h' ) ) ;
179178 } ) ;
180179 it ( 'Test 013 : should cp the file to the right target location when element has a target-dir' , ( ) => {
181180 const headers = copyArray ( valid_headers ) . filter ( s => s . targetDir !== undefined ) ;
182- const spy = spyOn ( shell , 'cp ' ) ;
181+ spyOn ( fs , 'copySync ' ) ;
183182 install ( headers [ 0 ] , dummyPluginInfo , dummyProject ) ;
184- expect ( spy ) . toHaveBeenCalledWith ( '-f' , path . join ( dummyplugin , 'src' , 'ios' , 'TargetDirTest.h' ) , path . join ( temp , 'SampleApp' , 'Plugins' , dummy_id , 'targetDir' , 'TargetDirTest.h' ) ) ;
183+ expect ( fs . copySync ) . toHaveBeenCalledWith ( path . join ( dummyplugin , 'src' , 'ios' , 'TargetDirTest.h' ) , path . join ( temp , 'SampleApp' , 'Plugins' , dummy_id , 'targetDir' , 'TargetDirTest.h' ) ) ;
185184 } ) ;
186185 } ) ;
187186
@@ -215,9 +214,9 @@ describe('ios plugin handler', () => {
215214 } ) ;
216215 it ( 'Test 017 : should cp the file to the right target location' , ( ) => {
217216 const resources = copyArray ( valid_resources ) ;
218- const spy = spyOn ( shell , 'cp ' ) ;
217+ spyOn ( fs , 'copySync ' ) ;
219218 install ( resources [ 0 ] , dummyPluginInfo , dummyProject ) ;
220- expect ( spy ) . toHaveBeenCalledWith ( '-f' , path . join ( dummyplugin , 'src' , 'ios' , 'DummyPlugin.bundle' ) , path . join ( temp , 'SampleApp' , 'Resources' , 'DummyPlugin.bundle' ) ) ;
219+ expect ( fs . copySync ) . toHaveBeenCalledWith ( path . join ( dummyplugin , 'src' , 'ios' , 'DummyPlugin.bundle' ) , path . join ( temp , 'SampleApp' , 'Resources' , 'DummyPlugin.bundle' ) ) ;
221220 } ) ;
222221
223222 it ( 'Test 018 : should link files to the right target location' , ( ) => {
@@ -274,9 +273,9 @@ describe('ios plugin handler', () => {
274273 } ) ;
275274 it ( 'Test 022 : should cp the file to the right target location' , ( ) => {
276275 const frameworks = copyArray ( valid_custom_frameworks ) ;
277- const spy = spyOn ( shell , 'cp ' ) ;
276+ spyOn ( fs , 'copySync ' ) ;
278277 install ( frameworks [ 0 ] , dummyPluginInfo , dummyProject ) ;
279- expect ( spy ) . toHaveBeenCalledWith ( '-Rf' , path . join ( dummyplugin , 'src' , 'ios' , 'Custom.framework' , '* ') ,
278+ expect ( fs . copySync ) . toHaveBeenCalledWith ( path . join ( dummyplugin , 'src' , 'ios' , 'Custom.framework' ) ,
280279 path . join ( temp , 'SampleApp/Plugins/org.test.plugins.dummyplugin/Custom.framework' ) ) ;
281280 } ) ;
282281
@@ -325,21 +324,21 @@ describe('ios plugin handler', () => {
325324 /* eslint-enable no-unused-vars */
326325
327326 beforeEach ( ( ) => {
328- spyOn ( shell , 'cp ' ) ;
327+ spyOn ( fs , 'copySync ' ) ;
329328 wwwDest = path . resolve ( dummyProject . www , asset . target ) ;
330329 platformWwwDest = path . resolve ( dummyProject . platformWww , asset . target ) ;
331330 } ) ;
332331
333332 it ( 'Test 026 : should put asset to both www and platform_www when options.usePlatformWww flag is specified' , ( ) => {
334333 install ( asset , dummyPluginInfo , dummyProject , { usePlatformWww : true } ) ;
335- expect ( shell . cp ) . toHaveBeenCalledWith ( '-f' , path . resolve ( dummyPluginInfo . dir , asset . src ) , path . resolve ( dummyProject . www , asset . target ) ) ;
336- expect ( shell . cp ) . toHaveBeenCalledWith ( '-f' , path . resolve ( dummyPluginInfo . dir , asset . src ) , path . resolve ( dummyProject . platformWww , asset . target ) ) ;
334+ expect ( fs . copySync ) . toHaveBeenCalledWith ( path . resolve ( dummyPluginInfo . dir , asset . src ) , path . resolve ( dummyProject . www , asset . target ) ) ;
335+ expect ( fs . copySync ) . toHaveBeenCalledWith ( path . resolve ( dummyPluginInfo . dir , asset . src ) , path . resolve ( dummyProject . platformWww , asset . target ) ) ;
337336 } ) ;
338337
339338 it ( 'Test 027 : should put asset to www only when options.usePlatformWww flag is not specified' , ( ) => {
340339 install ( asset , dummyPluginInfo , dummyProject ) ;
341- expect ( shell . cp ) . toHaveBeenCalledWith ( '-f' , path . resolve ( dummyPluginInfo . dir , asset . src ) , path . resolve ( dummyProject . www , asset . target ) ) ;
342- expect ( shell . cp ) . not . toHaveBeenCalledWith ( path . resolve ( dummyPluginInfo . dir , asset . src ) , path . resolve ( dummyProject . platformWww , asset . target ) ) ;
340+ expect ( fs . copySync ) . toHaveBeenCalledWith ( path . resolve ( dummyPluginInfo . dir , asset . src ) , path . resolve ( dummyProject . www , asset . target ) ) ;
341+ expect ( fs . copySync ) . not . toHaveBeenCalledWith ( path . resolve ( dummyPluginInfo . dir , asset . src ) , path . resolve ( dummyProject . platformWww , asset . target ) ) ;
343342 } ) ;
344343 } ) ;
345344
0 commit comments