@@ -793,7 +793,7 @@ test("install --save with new dependency should be deterministic", async () => {
793
793
} ) ;
794
794
} ) ;
795
795
796
- test . only ( "install --save with new dependency should be deterministic 2" , async ( ) => {
796
+ test ( "install --save with new dependency should be deterministic 2" , async ( ) => {
797
797
// mime-types@2.0.0->mime-db@1.0.1 is saved in local mirror and is deduped
798
798
// install mime-db@1.0.3 should replace mime-db@1.0.1 in root
799
799
@@ -845,3 +845,46 @@ test.only("install --save with new dependency should be deterministic 2", async
845
845
} ) ;
846
846
} ) ;
847
847
} ) ;
848
+
849
+
850
+ test ( "install --save should ignore cache" , ( ) => {
851
+ // left-pad@1.1.0 gets installed without --save
852
+ // left-pad@1.1.0 gets installed with --save
853
+ // files in mirror, fbkpm.lock, package.json and node_modules should reflect that
854
+
855
+ let mirrorPath = "mirror-for-offline" ;
856
+
857
+ let fixture = "install-save-to-mirror-when-cached" ;
858
+ return run ( { } , [ "left-pad@1.1.0" ] , fixture , async ( config ) => {
859
+ assert . equal (
860
+ JSON . parse ( await fs . readFile ( path . join ( config . cwd , "node_modules/left-pad/package.json" ) ) ) . version ,
861
+ "1.1.0"
862
+ ) ;
863
+
864
+ return run ( { save : true } , [ "left-pad@1.1.0" ] , fixture , async ( config ) => {
865
+ assert . equal (
866
+ JSON . parse ( await fs . readFile ( path . join ( config . cwd , "node_modules/left-pad/package.json" ) ) ) . version ,
867
+ "1.1.0"
868
+ ) ;
869
+ assert . deepEqual (
870
+ JSON . parse ( await fs . readFile ( path . join ( config . cwd , "package.json" ) ) ) . dependencies ,
871
+ { "left-pad" : "1.1.0" }
872
+ ) ;
873
+
874
+ let lockFileWritten = await fs . readFile ( path . join ( config . cwd , "fbkpm.lock" ) ) ;
875
+ let lockFileLines = lockFileWritten . split ( "\n" ) . filter ( ( line ) => ! ! line ) ;
876
+ assert . equal ( lockFileLines [ 0 ] , "left-pad@1.1.0:" ) ;
877
+ assert . equal ( lockFileLines . length , 4 ) ;
878
+ assert . notEqual ( lockFileLines [ 3 ] . indexOf ( "resolved left-pad-1.1.0.tgz" ) , - 1 ) ;
879
+
880
+ throw new Error ( "AA" )
881
+
882
+ let mirror = await fs . walk ( path . join ( config . cwd , mirrorPath ) ) ;
883
+ assert . equal ( mirror . length , 1 ) ;
884
+ assert . equal ( mirror [ 0 ] . relative , "left-pad-1.1.0.tgz" ) ;
885
+ await fs . unlink ( path . join ( config . cwd , mirrorPath ) ) ;
886
+ await fs . unlink ( path . join ( config . cwd , "package.json" ) ) ;
887
+
888
+ } ) ;
889
+ } ) ;
890
+ } ) ;
0 commit comments