File tree 2 files changed +29
-0
lines changed
2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,9 @@ class DirFetcher extends Fetcher {
32
32
if ( ! mani . scripts || ! mani . scripts . prepare ) {
33
33
return
34
34
}
35
+ if ( this . opts . ignoreScripts ) {
36
+ return
37
+ }
35
38
36
39
// we *only* run prepare.
37
40
// pre/post-pack is run by the npm CLI for publish and pack,
Original file line number Diff line number Diff line change @@ -164,3 +164,29 @@ t.test('fails without a tree or constructor', async t => {
164
164
const f = new DirFetcher ( abbrevspec , { } )
165
165
t . rejects ( ( ) => f . extract ( me + '/prepare' ) )
166
166
} )
167
+
168
+ t . test ( 'with prepare script and ignoreScripts true' , async t => {
169
+ let shouldNotBePopulated = false
170
+
171
+ const DirFetcherIsolate = t . mock ( '../lib/dir.js' , {
172
+ '@npmcli/run-script' : ( ) => {
173
+ shouldNotBePopulated = true
174
+ } ,
175
+ } )
176
+
177
+ const dir = t . testdir ( {
178
+ 'package.json' : JSON . stringify ( {
179
+ name : 'meow' ,
180
+ version : '1.0.0' ,
181
+ scripts : {
182
+ prepare : 'noop' ,
183
+ } ,
184
+ } ) ,
185
+ } )
186
+ const f = new DirFetcherIsolate ( `file:${ relative ( process . cwd ( ) , dir ) } ` , {
187
+ tree : await loadActual ( dir ) ,
188
+ ignoreScripts : true ,
189
+ } )
190
+ await f . extract ( me + '/prepare-ignore' )
191
+ t . ok ( ! shouldNotBePopulated )
192
+ } )
You can’t perform that action at this time.
0 commit comments