@@ -9,23 +9,23 @@ const fs = require("fs-extra");
9
9
const path = require ( "path" ) ;
10
10
11
11
// mocked or stubbed modules
12
- const rimrafDir = require ( "@lerna/rimraf-dir" ) ;
13
- const npmInstall = require ( "@lerna/npm-install" ) ;
14
- const runLifecycle = require ( "@lerna/run-lifecycle" ) ;
15
- const createSymlink = require ( "@lerna/create-symlink" ) ;
16
- const hasNpmVersion = require ( "@lerna/has-npm-version" ) ;
12
+ const { rimrafDir } = require ( "@lerna/rimraf-dir" ) ;
13
+ const { npmInstall, npmInstallDependencies } = require ( "@lerna/npm-install" ) ;
14
+ const { runLifecycle } = require ( "@lerna/run-lifecycle" ) ;
15
+ const { createSymlink } = require ( "@lerna/create-symlink" ) ;
16
+ const { hasNpmVersion } = require ( "@lerna/has-npm-version" ) ;
17
17
18
18
// helpers
19
19
const initFixture = require ( "@lerna-test/init-fixture" ) ( __dirname ) ;
20
- const normalizeRelativeDir = require ( "@lerna-test/normalize-relative-dir" ) ;
21
- const updateLernaConfig = require ( "@lerna-test/update-lerna-config" ) ;
20
+ const { normalizeRelativeDir } = require ( "@lerna-test/normalize-relative-dir" ) ;
21
+ const { updateLernaConfig } = require ( "@lerna-test/update-lerna-config" ) ;
22
22
23
23
// file under test
24
24
const lernaBootstrap = require ( "@lerna-test/command-runner" ) ( require ( "../command" ) ) ;
25
25
26
26
// assertion helpers
27
27
const installedPackagesInDirectories = ( testDir ) =>
28
- npmInstall . dependencies . mock . calls . reduce ( ( obj , [ pkg , dependencies ] ) => {
28
+ npmInstallDependencies . mock . calls . reduce ( ( obj , [ pkg , dependencies ] ) => {
29
29
const relative = normalizeRelativeDir ( testDir , pkg . location ) ;
30
30
obj [ relative || "ROOT" ] = dependencies ;
31
31
return obj ;
@@ -64,7 +64,7 @@ describe("BootstrapCommand", () => {
64
64
// we stub npmInstall in most tests because
65
65
// we already have enough tests of npmInstall
66
66
npmInstall . mockResolvedValue ( ) ;
67
- npmInstall . dependencies . mockResolvedValue ( ) ;
67
+ npmInstallDependencies . mockResolvedValue ( ) ;
68
68
69
69
// stub runLifecycle because it is a huge source
70
70
// of slowness when running tests for no good reason
@@ -111,7 +111,7 @@ describe("BootstrapCommand", () => {
111
111
await lernaBootstrap ( testDir ) ( "--ignore-scripts" ) ;
112
112
113
113
expect ( runLifecycle ) . not . toHaveBeenCalled ( ) ;
114
- expect ( npmInstall . dependencies ) . toHaveBeenCalledWith (
114
+ expect ( npmInstallDependencies ) . toHaveBeenCalledWith (
115
115
expect . objectContaining ( {
116
116
name : "package-prepare" ,
117
117
} ) ,
@@ -144,7 +144,7 @@ describe("BootstrapCommand", () => {
144
144
expect ( removedDirectories ( testDir ) ) . toMatchSnapshot ( ) ;
145
145
146
146
// root includes explicit dependencies and hoisted from leaves
147
- expect ( npmInstall . dependencies ) . toHaveBeenCalledWith (
147
+ expect ( npmInstallDependencies ) . toHaveBeenCalledWith (
148
148
expect . objectContaining ( {
149
149
name : "basic" ,
150
150
} ) ,
@@ -159,7 +159,7 @@ describe("BootstrapCommand", () => {
159
159
) ;
160
160
161
161
// [email protected] differs from the more common foo@^1.0.0
162
- expect ( npmInstall . dependencies ) . toHaveBeenLastCalledWith (
162
+ expect ( npmInstallDependencies ) . toHaveBeenLastCalledWith (
163
163
expect . objectContaining ( {
164
164
name : "package-3" ,
165
165
} ) ,
@@ -219,7 +219,7 @@ describe("BootstrapCommand", () => {
219
219
await lernaBootstrap ( testDir ) ( "--ci" ) ;
220
220
221
221
expect ( hasNpmVersion ) . toHaveBeenLastCalledWith ( ">=5.7.0" ) ;
222
- expect ( npmInstall . dependencies . mock . calls [ 0 ] [ 2 ] ) . toEqual ( {
222
+ expect ( npmInstallDependencies . mock . calls [ 0 ] [ 2 ] ) . toEqual ( {
223
223
subCommand : "ci" ,
224
224
registry : undefined ,
225
225
npmClient : "npm" ,
@@ -236,7 +236,7 @@ describe("BootstrapCommand", () => {
236
236
237
237
await lernaBootstrap ( testDir ) ( "--ci" ) ;
238
238
239
- expect ( npmInstall . dependencies . mock . calls [ 0 ] [ 2 ] ) . toEqual ( {
239
+ expect ( npmInstallDependencies . mock . calls [ 0 ] [ 2 ] ) . toEqual ( {
240
240
registry : undefined ,
241
241
npmClient : "npm" ,
242
242
npmClientArgs : [ ] ,
@@ -250,7 +250,7 @@ describe("BootstrapCommand", () => {
250
250
251
251
await lernaBootstrap ( testDir ) ( "--hoist" , "package-*" , "--ci" ) ;
252
252
253
- expect ( npmInstall . dependencies . mock . calls [ 0 ] [ 2 ] ) . toMatchObject ( {
253
+ expect ( npmInstallDependencies . mock . calls [ 0 ] [ 2 ] ) . toMatchObject ( {
254
254
subCommand : "install" , // not "ci"
255
255
npmClient : "npm" ,
256
256
npmClientArgs : [ "--no-save" ] ,
@@ -270,7 +270,7 @@ describe("BootstrapCommand", () => {
270
270
await lernaBootstrap ( testDir ) ( ) ;
271
271
272
272
expect ( hasNpmVersion ) . not . toHaveBeenCalled ( ) ;
273
- expect ( npmInstall . dependencies . mock . calls [ 0 ] [ 2 ] ) . toEqual ( {
273
+ expect ( npmInstallDependencies . mock . calls [ 0 ] [ 2 ] ) . toEqual ( {
274
274
registry : undefined ,
275
275
npmClient : "npm" ,
276
276
npmClientArgs : [ ] ,
@@ -350,7 +350,7 @@ describe("BootstrapCommand", () => {
350
350
351
351
expect ( installedPackagesInDirectories ( testDir ) ) . toMatchSnapshot ( ) ;
352
352
expect ( symlinkedDirectories ( testDir ) ) . toMatchSnapshot ( ) ;
353
- expect ( npmInstall . dependencies . mock . calls [ 0 ] [ 2 ] ) . toMatchObject ( {
353
+ expect ( npmInstallDependencies . mock . calls [ 0 ] [ 2 ] ) . toMatchObject ( {
354
354
subCommand : "install" , // not "ci"
355
355
npmClient : "npm" ,
356
356
npmClientArgs : [ "--no-save" ] ,
@@ -362,7 +362,7 @@ describe("BootstrapCommand", () => {
362
362
363
363
await lernaBootstrap ( testDir ) ( "--scope" , "@test/package-2" , "--npm-client" , "yarn" , "--ci" ) ;
364
364
365
- expect ( npmInstall . dependencies . mock . calls [ 0 ] [ 2 ] ) . toMatchObject ( {
365
+ expect ( npmInstallDependencies . mock . calls [ 0 ] [ 2 ] ) . toMatchObject ( {
366
366
npmClient : "yarn" ,
367
367
npmClientArgs : [ "--pure-lockfile" ] ,
368
368
} ) ;
@@ -373,7 +373,7 @@ describe("BootstrapCommand", () => {
373
373
374
374
await lernaBootstrap ( testDir ) ( ) ;
375
375
376
- expect ( npmInstall . dependencies ) . toHaveBeenCalledWith (
376
+ expect ( npmInstallDependencies ) . toHaveBeenCalledWith (
377
377
expect . objectContaining ( {
378
378
name : "@test/package-2" ,
379
379
} ) ,
@@ -450,7 +450,7 @@ describe("BootstrapCommand", () => {
450
450
451
451
await lernaBootstrap ( testDir ) ( "--npm-client" , "yarn" ) ;
452
452
453
- expect ( npmInstall . dependencies . mock . calls [ 0 ] [ 2 ] ) . toMatchObject ( {
453
+ expect ( npmInstallDependencies . mock . calls [ 0 ] [ 2 ] ) . toMatchObject ( {
454
454
npmClient : "yarn" ,
455
455
mutex : expect . stringMatching ( / ^ n e t w o r k : \d + $ / ) ,
456
456
} ) ;
@@ -461,7 +461,7 @@ describe("BootstrapCommand", () => {
461
461
462
462
await lernaBootstrap ( testDir ) ( "--npm-client" , "yarn" , "--mutex" , "file:/test/this/path" ) ;
463
463
464
- expect ( npmInstall . dependencies . mock . calls [ 0 ] [ 2 ] ) . toMatchObject ( {
464
+ expect ( npmInstallDependencies . mock . calls [ 0 ] [ 2 ] ) . toMatchObject ( {
465
465
npmClient : "yarn" ,
466
466
mutex : "file:/test/this/path" ,
467
467
} ) ;
@@ -486,7 +486,7 @@ describe("BootstrapCommand", () => {
486
486
487
487
await lernaBootstrap ( testDir ) ( ) ;
488
488
489
- expect ( npmInstall . dependencies ) . not . toHaveBeenCalled ( ) ;
489
+ expect ( npmInstallDependencies ) . not . toHaveBeenCalled ( ) ;
490
490
} ) ;
491
491
492
492
it ( "hoists appropriately" , async ( ) => {
@@ -531,7 +531,7 @@ describe("BootstrapCommand", () => {
531
531
532
532
await lernaBootstrap ( testDir ) ( ) ;
533
533
534
- expect ( npmInstall . dependencies ) . not . toHaveBeenCalled ( ) ;
534
+ expect ( npmInstallDependencies ) . not . toHaveBeenCalled ( ) ;
535
535
} ) ;
536
536
} ) ;
537
537
@@ -542,7 +542,7 @@ describe("BootstrapCommand", () => {
542
542
await lernaBootstrap ( testDir ) ( ) ;
543
543
544
544
expect ( installedPackagesInDirectories ( testDir ) ) . toMatchSnapshot ( ) ;
545
- expect ( npmInstall . dependencies ) . toHaveBeenLastCalledWith (
545
+ expect ( npmInstallDependencies ) . toHaveBeenLastCalledWith (
546
546
expect . objectContaining ( {
547
547
name : "@test/package-1" ,
548
548
} ) ,
@@ -563,7 +563,7 @@ describe("BootstrapCommand", () => {
563
563
564
564
await lernaBootstrap ( testDir ) ( "--" , "--no-optional" , "--production" ) ;
565
565
566
- expect ( npmInstall . dependencies . mock . calls [ 0 ] [ 2 ] ) . toMatchObject ( {
566
+ expect ( npmInstallDependencies . mock . calls [ 0 ] [ 2 ] ) . toMatchObject ( {
567
567
npmClientArgs : [ "--no-optional" , "--production" ] ,
568
568
} ) ;
569
569
} ) ;
@@ -575,7 +575,7 @@ describe("BootstrapCommand", () => {
575
575
576
576
await lernaBootstrap ( testDir ) ( "--" , "--no-optional" ) ;
577
577
578
- expect ( npmInstall . dependencies . mock . calls [ 0 ] [ 2 ] ) . toMatchObject ( {
578
+ expect ( npmInstallDependencies . mock . calls [ 0 ] [ 2 ] ) . toMatchObject ( {
579
579
npmClientArgs : [ "--production" , "--no-optional" ] ,
580
580
} ) ;
581
581
} ) ;
@@ -588,7 +588,7 @@ describe("BootstrapCommand", () => {
588
588
589
589
await lernaBootstrap ( testDir ) ( ) ;
590
590
591
- expect ( npmInstall . dependencies ) . not . toHaveBeenCalled ( ) ;
591
+ expect ( npmInstallDependencies ) . not . toHaveBeenCalled ( ) ;
592
592
expect ( npmInstall ) . toHaveBeenLastCalledWith (
593
593
expect . objectContaining ( { name : "root" } ) ,
594
594
expect . objectContaining ( {
@@ -614,7 +614,7 @@ describe("BootstrapCommand", () => {
614
614
615
615
await lernaBootstrap ( testDir ) ( ) ;
616
616
617
- expect ( npmInstall . dependencies ) . not . toHaveBeenCalled ( ) ;
617
+ expect ( npmInstallDependencies ) . not . toHaveBeenCalled ( ) ;
618
618
expect ( npmInstall ) . toHaveBeenLastCalledWith (
619
619
expect . objectContaining ( { name : "relative-file-specs" } ) ,
620
620
expect . objectContaining ( {
0 commit comments