@@ -79,6 +79,30 @@ t.test('reifies, audits, removes node_modules', async t => {
79
79
t . equal ( fs . existsSync ( nmAbbrev ) , true , 'installs abbrev' )
80
80
} )
81
81
82
+ t . test ( 'reifies, audits, removes node_modules on repeat run' , async t => {
83
+ const { npm, joinedOutput, registry } = await loadMockNpm ( t , {
84
+ prefixDir : {
85
+ abbrev : abbrev ,
86
+ 'package.json' : JSON . stringify ( packageJson ) ,
87
+ 'package-lock.json' : JSON . stringify ( packageLock ) ,
88
+ node_modules : { test : 'test file that will be removed' } ,
89
+ } ,
90
+ } )
91
+ const manifest = registry . manifest ( { name : 'abbrev' } )
92
+ await registry . tarball ( {
93
+ manifest : manifest . versions [ '1.0.0' ] ,
94
+ tarball : path . join ( npm . prefix , 'abbrev' ) ,
95
+ } )
96
+ registry . nock . post ( '/-/npm/v1/security/advisories/bulk' ) . reply ( 200 , { } )
97
+ await npm . exec ( 'ci' , [ ] )
98
+ await npm . exec ( 'ci' , [ ] )
99
+ t . match ( joinedOutput ( ) , 'added 1 package, and audited 2 packages in' )
100
+ const nmTest = path . join ( npm . prefix , 'node_modules' , 'test' )
101
+ t . equal ( fs . existsSync ( nmTest ) , false , 'existing node_modules is removed' )
102
+ const nmAbbrev = path . join ( npm . prefix , 'node_modules' , 'abbrev' )
103
+ t . equal ( fs . existsSync ( nmAbbrev ) , true , 'installs abbrev' )
104
+ } )
105
+
82
106
t . test ( '--no-audit and --ignore-scripts' , async t => {
83
107
const { npm, joinedOutput, registry } = await loadMockNpm ( t , {
84
108
config : {
0 commit comments