@@ -883,34 +883,36 @@ test("[network] install --save should ignore cache", () => {
883
883
let mirrorPath = "mirror-for-offline" ;
884
884
885
885
let fixture = "install-save-to-mirror-when-cached" ;
886
- return run ( { } , [ "left-pad@1.1.0" ] , fixture , async ( config ) => {
886
+ return run ( { } , [ "left-pad@1.1.0" ] , fixture , async ( config , reporter ) => {
887
887
assert . equal (
888
888
await getPackageVersion ( config , "left-pad" ) ,
889
889
"1.1.0"
890
890
) ;
891
891
892
- return run ( { save : true } , [ "left-pad@1.1.0" ] , fixture , async ( config ) => {
893
- assert . equal (
894
- await getPackageVersion ( config , "left-pad" ) ,
895
- "1.1.0"
896
- ) ;
897
- assert . deepEqual (
898
- JSON . parse ( await fs . readFile ( path . join ( config . cwd , "package.json" ) ) ) . dependencies ,
899
- { "left-pad" : "1.1.0" }
900
- ) ;
892
+ let lockfile = await createLockfile ( config . cwd , false , true ) ;
893
+ let install = new Install ( "install" , { save : true } , [ "left-pad@1.1.0" ] , config , reporter , lockfile ) ;
894
+ await install . init ( ) ;
895
+ assert . equal (
896
+ await getPackageVersion ( config , "left-pad" ) ,
897
+ "1.1.0"
898
+ ) ;
899
+ assert . deepEqual (
900
+ JSON . parse ( await fs . readFile ( path . join ( config . cwd , "package.json" ) ) ) . dependencies ,
901
+ { "left-pad" : "1.1.0" }
902
+ ) ;
901
903
902
- let lockFileWritten = await fs . readFile ( path . join ( config . cwd , "fbkpm.lock" ) ) ;
903
- let lockFileLines = lockFileWritten . split ( "\n" ) . filter ( ( line ) => ! ! line ) ;
904
- assert . equal ( lockFileLines [ 0 ] , "left-pad@1.1.0:" ) ;
905
- assert . equal ( lockFileLines . length , 4 ) ;
906
- assert . notEqual ( lockFileLines [ 3 ] . indexOf ( "resolved left-pad-1.1.0.tgz" ) , - 1 ) ;
904
+ let mirror = await fs . walk ( path . join ( config . cwd , mirrorPath ) ) ;
905
+ assert . equal ( mirror . length , 1 ) ;
906
+ assert . equal ( mirror [ 0 ] . relative , "left-pad-1.1.0.tgz" ) ;
907
907
908
- let mirror = await fs . walk ( path . join ( config . cwd , mirrorPath ) ) ;
909
- assert . equal ( mirror . length , 1 ) ;
910
- assert . equal ( mirror [ 0 ] . relative , "left-pad-1.1.0.tgz" ) ;
911
- await fs . unlink ( path . join ( config . cwd , mirrorPath ) ) ;
912
- await fs . unlink ( path . join ( config . cwd , "package.json" ) ) ;
908
+ let lockFileWritten = await fs . readFile ( path . join ( config . cwd , "fbkpm.lock" ) ) ;
909
+ let lockFileLines = lockFileWritten . split ( "\n" ) . filter ( ( line ) => ! ! line ) ;
910
+ assert . equal ( lockFileLines [ 0 ] , "left-pad@1.1.0:" ) ;
911
+ assert . equal ( lockFileLines . length , 4 ) ;
912
+ assert . notEqual ( lockFileLines [ 3 ] . indexOf ( "resolved left-pad-1.1.0.tgz" ) , - 1 ) ;
913
+
914
+ await fs . unlink ( path . join ( config . cwd , mirrorPath ) ) ;
915
+ await fs . unlink ( path . join ( config . cwd , "package.json" ) ) ;
913
916
914
- } ) ;
915
917
} ) ;
916
918
} ) ;
0 commit comments