This repository was archived by the owner on May 10, 2021. It is now read-only.
File tree 1 file changed +39
-0
lines changed
1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -168,6 +168,45 @@ test('handles dependency list with only shallow subdeps', t => {
168
168
} )
169
169
} )
170
170
171
+ test ( 'deletes node_modules/ contents, without deleting node_modules/ itself' , t => {
172
+ const fixture = new Tacks ( Dir ( {
173
+ 'node_modules' : Dir ( {
174
+ 'stale-dependency' : Dir ( {
175
+ 'package.json' : File ( {
176
+ name : 'stale-dependency' ,
177
+ version : '1.0.0'
178
+ } )
179
+ } )
180
+ } ) ,
181
+ 'package.json' : File ( {
182
+ name : pkgName ,
183
+ version : pkgVersion
184
+ } ) ,
185
+ 'package-lock.json' : File ( {
186
+ dependencies : { } ,
187
+ lockfileVersion : 1
188
+ } )
189
+ } ) )
190
+ fixture . create ( prefix )
191
+
192
+ let notNodeModulesDeleted = true
193
+ const nodeModulesDir = path . join ( prefix , 'node_modules' )
194
+ const watcher = fs . watch ( nodeModulesDir , ( ) => {
195
+ if ( ! fs . existsSync ( nodeModulesDir ) ) {
196
+ notNodeModulesDeleted = false
197
+ }
198
+ } )
199
+
200
+ return run ( ) . then ( ( ) => {
201
+ t . ok (
202
+ ! fs . existsSync ( path . join ( nodeModulesDir , 'stale-dependency' ) ) ,
203
+ 'node_modules/ contents were deleted'
204
+ )
205
+ watcher . close ( )
206
+ t . ok ( notNodeModulesDeleted , 'node_modules/ itself was not deleted' )
207
+ } )
208
+ } )
209
+
171
210
test ( 'handles dependency list with only deep subdeps' , t => {
172
211
const fixture = new Tacks ( Dir ( {
173
212
'package.json' : File ( {
You can’t perform that action at this time.
0 commit comments