@@ -337,7 +337,7 @@ test("upgrade scenario", () => {
337
337
} , clean ) ;
338
338
} ) ;
339
339
340
- test . only ( "upgrade scenario 2 (with sub dependencies)" , async ( ) => {
340
+ test ( "upgrade scenario 2 (with sub dependencies)" , async ( ) => {
341
341
// mime-types@2.0.0 is saved in local mirror and gets updated to mime-types@2.1.11
342
342
// files in mirror, fbkpm.lock, package.json and node_modules should reflect that
343
343
@@ -591,7 +591,6 @@ test("uninstall should remove subdependencies", () => {
591
591
await uninstall ( config , reporter , { } , [ "dep-a" ] ) ;
592
592
593
593
assert ( ! await fs . exists ( path . join ( config . cwd , "node_modules/dep-a" ) ) ) ;
594
- // TODO dep-b did not get removed
595
594
assert ( ! await fs . exists ( path . join ( config . cwd , "node_modules/dep-b" ) ) ) ;
596
595
assert ( await fs . exists ( path . join ( config . cwd , "node_modules/dep-c" ) ) ) ;
597
596
@@ -618,4 +617,36 @@ test("uninstall should remove subdependencies", () => {
618
617
} ) ;
619
618
} ) ;
620
619
620
+ test ( "install --save should add missing deps to fbkpm and mirror (PR import scenario)" , async ( ) => {
621
+ let mirrorPath = "mirror-for-offline" ;
622
+ let fixture = "install-init-mirror" ;
623
+ let cwd = path . join ( fixturesLoc , fixture ) ;
624
+ await fs . copy ( path . join ( cwd , "fbkpm.lock.before" ) , path . join ( cwd , "fbkpm.lock" ) ) ;
625
+
626
+ return run ( { save : true } , [ ] , fixture , async ( config , reporter ) => {
627
+ assert . equal ( JSON . parse ( await fs . readFile ( path . join ( config . cwd ,
628
+ "node_modules/mime-types/package.json" ) ) ) . version , "2.0.0" ) ;
629
+ assert ( semver . satisfies ( JSON . parse ( await fs . readFile ( path . join ( config . cwd ,
630
+ "node_modules/mime-db/package.json" ) ) ) . version , "~1.0.1" ) ) ;
631
+ assert . equal ( JSON . parse ( await fs . readFile ( path . join ( config . cwd ,
632
+ "node_modules/fake-fbkpm-dependency/package.json" ) ) ) . version , "1.0.1" ) ;
633
+
634
+ let mirror = await fs . walk ( path . join ( config . cwd , mirrorPath ) ) ;
635
+ assert . equal ( mirror . length , 3 ) ;
636
+ assert . equal ( mirror [ 0 ] . relative , "fake-fbkpm-dependency-1.0.1.tgz" ) ;
637
+ assert . equal ( mirror [ 1 ] . relative . indexOf ( "mime-db-1.0." ) , 0 ) ;
638
+ assert . equal ( mirror [ 2 ] . relative , "mime-types-2.0.0.tgz" ) ;
639
+
640
+ let lockFileContent = await fs . readFile ( path . join ( config . cwd , "fbkpm.lock" ) ) ;
641
+ let lockFileLines = lockFileContent . split ( "\n" ) . filter ( ( line ) => ! ! line ) ;
642
+ assert . equal ( lockFileLines . length , 14 ) ;
643
+ assert . equal ( lockFileLines [ 4 ] . indexOf ( "mime-db@" ) , 0 ) ;
644
+ assert . equal ( lockFileLines [ 8 ] . indexOf ( "mime-types@2.0.0" ) , 0 ) ;
645
+
646
+ await fs . unlink ( path . join ( mirror [ 1 ] . absolute ) ) ;
647
+ await fs . unlink ( path . join ( mirror [ 2 ] . absolute ) ) ;
648
+ await fs . unlink ( path . join ( config . cwd , "fbkpm.lock" ) ) ;
649
+
650
+ } ) ;
651
+ } ) ;
621
652
0 commit comments