@@ -28,6 +28,18 @@ var conf = {
28
28
} )
29
29
}
30
30
31
+ const confPkgLockFalse = {
32
+ cwd : testdir ,
33
+ env : Object . assign ( { } , process . env , {
34
+ npm_config_cache : cachedir ,
35
+ npm_config_tmp : tmpdir ,
36
+ npm_config_prefix : globaldir ,
37
+ npm_config_registry : common . registry ,
38
+ npm_config_loglevel : 'warn' ,
39
+ npm_config_package_lock : false
40
+ } )
41
+ }
42
+
31
43
var server
32
44
var fixture = new Tacks ( Dir ( {
33
45
cache : Dir ( ) ,
@@ -54,7 +66,6 @@ function cleanup () {
54
66
}
55
67
56
68
test ( 'setup' , function ( t ) {
57
- setup ( )
58
69
mr ( { port : common . port , throwOnUnmatched : true } , function ( err , s ) {
59
70
if ( err ) throw err
60
71
server = s
@@ -63,6 +74,7 @@ test('setup', function (t) {
63
74
} )
64
75
65
76
test ( 'package-lock-only' , function ( t ) {
77
+ setup ( )
66
78
return common . npm ( [ 'install' , '--package-lock-only' ] , conf ) . spread ( ( code , stdout , stderr ) => {
67
79
t . is ( code , 0 , 'command ran ok' )
68
80
t . comment ( stdout . trim ( ) )
@@ -78,6 +90,32 @@ test('package-lock-only', function (t) {
78
90
} )
79
91
} )
80
92
93
+ test ( '--package-lock-only with --package-lock negates `package_lock: false`' , function ( t ) {
94
+ setup ( )
95
+ return common . npm ( [ 'install' , '--package-lock' , '--package-lock-only' ] , confPkgLockFalse ) . spread ( ( code , stdout , stderr ) => {
96
+ t . is ( code , 0 , 'ok' )
97
+ t . comment ( stdout . trim ( ) )
98
+ t . comment ( stderr . trim ( ) )
99
+
100
+ // Verify that package-lock.json exists.
101
+ t . ok ( fs . existsSync ( pkgLockPath ) , 'ensure that package-lock.json was created' )
102
+ t . end ( )
103
+ } )
104
+ } )
105
+
106
+ test ( 'package-lock-only creates package_lock.json when config has `package_lock: false`' , function ( t ) {
107
+ setup ( )
108
+ return common . npm ( [ 'install' , '--package-lock-only' ] , confPkgLockFalse ) . spread ( ( code , stdout , stderr ) => {
109
+ t . is ( code , 0 , 'ok' )
110
+ t . comment ( stdout . trim ( ) )
111
+ t . comment ( stderr . trim ( ) )
112
+
113
+ // Verify that package-lock.json exists.
114
+ t . ok ( fs . existsSync ( pkgLockPath ) , 'ensure that package-lock.json was created' )
115
+ t . end ( )
116
+ } )
117
+ } )
118
+
81
119
test ( 'cleanup' , function ( t ) {
82
120
server . close ( )
83
121
cleanup ( )
0 commit comments