@@ -212,6 +212,53 @@ describe('packExternalModules', () => {
212
212
] ) ) ;
213
213
} ) ;
214
214
215
+ it ( 'should skip module copy for Google provider' , ( ) => {
216
+ const expectedCompositePackageJSON = {
217
+ name : 'test-service' ,
218
+ version : '1.0.0' ,
219
+ description : 'Packaged externals for test-service' ,
220
+ private : true ,
221
+ dependencies : {
222
+ '@scoped/vendor' : '1.0.0' ,
223
+ uuid : '^5.4.1' ,
224
+ bluebird : '^3.4.0'
225
+ }
226
+ } ;
227
+ const expectedPackageJSON = {
228
+ dependencies : {
229
+ '@scoped/vendor' : '1.0.0' ,
230
+ uuid : '^5.4.1' ,
231
+ bluebird : '^3.4.0'
232
+ }
233
+ } ;
234
+
235
+ _ . set ( serverless , 'service.provider.name' , 'google' ) ;
236
+ module . webpackOutputPath = 'outputPath' ;
237
+ fsExtraMock . pathExists . yields ( null , false ) ;
238
+ fsExtraMock . copy . yields ( ) ;
239
+ childProcessMock . exec . onFirstCall ( ) . yields ( null , '{}' , '' ) ;
240
+ childProcessMock . exec . onSecondCall ( ) . yields ( null , '' , '' ) ;
241
+ childProcessMock . exec . onThirdCall ( ) . yields ( ) ;
242
+ module . compileStats = stats ;
243
+ return expect ( module . packExternalModules ( ) ) . to . be . fulfilled
244
+ . then ( ( ) => BbPromise . all ( [
245
+ // The module package JSON and the composite one should have been stored
246
+ expect ( writeFileSyncStub ) . to . have . been . calledTwice ,
247
+ expect ( writeFileSyncStub . firstCall . args [ 1 ] ) . to . equal ( JSON . stringify ( expectedCompositePackageJSON , null , 2 ) ) ,
248
+ expect ( writeFileSyncStub . secondCall . args [ 1 ] ) . to . equal ( JSON . stringify ( expectedPackageJSON , null , 2 ) ) ,
249
+ // The modules should have been copied
250
+ expect ( fsExtraMock . copy ) . to . have . not . been . called ,
251
+ // npm ls and npm prune should have been called
252
+ expect ( childProcessMock . exec ) . to . have . been . calledTwice ,
253
+ expect ( childProcessMock . exec . firstCall ) . to . have . been . calledWith (
254
+ 'npm ls -prod -json -depth=1'
255
+ ) ,
256
+ expect ( childProcessMock . exec . secondCall ) . to . have . been . calledWith (
257
+ 'npm install'
258
+ )
259
+ ] ) ) ;
260
+ } ) ;
261
+
215
262
it ( 'should reject if npm install fails' , ( ) => {
216
263
module . webpackOutputPath = 'outputPath' ;
217
264
fsExtraMock . pathExists . yields ( null , false ) ;
0 commit comments