Skip to content
This repository was archived by the owner on Aug 11, 2021. It is now read-only.

Commit b136ac8

Browse files
addaleaxiarna
authored andcommitted
lifecycle: move ignore-scripts handling to actual place of use
Instead of overriding `pkg.scripts` when `ignore-scripts` is in effect, test the option when actually determining whether there is a script to invoke. Otherwise, published packages will not contain the proper `scripts:` fields when `ignore-scripts` is `true`. Fixes: npm/npm#16243 PR-URL: npm/npm#16476 Credit: @addaleax Reviewed-By: @iarna
1 parent 0329828 commit b136ac8

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

index.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ function lifecycle (pkg, stage, wd, opts) {
3737
opts.log.info('lifecycle', logid(pkg, stage), pkg._id)
3838
if (!pkg.scripts) pkg.scripts = {}
3939

40-
if (opts.ignoreScripts) {
41-
opts.log.info('lifecycle', logid(pkg, stage), 'ignored because ignore-scripts is set to true', pkg._id)
42-
pkg.scripts = {}
43-
}
4440
if (stage === 'prepublish' && opts.ignorePrepublish) {
4541
opts.log.info('lifecycle', logid(pkg, stage), 'ignored because ignore-prepublish is set to true', pkg._id)
4642
delete pkg.scripts.prepublish
@@ -107,7 +103,10 @@ function lifecycle_ (pkg, stage, wd, opts, env, cb) {
107103

108104
var packageLifecycle = pkg.scripts && pkg.scripts.hasOwnProperty(stage)
109105

110-
if (packageLifecycle) {
106+
if (opts.ignoreScripts) {
107+
opts.log.info('lifecycle', logid(pkg, stage), 'ignored because ignore-scripts is set to true', pkg._id)
108+
packageLifecycle = false
109+
} else if (packageLifecycle) {
111110
// define this here so it's available to all scripts.
112111
env.npm_lifecycle_script = pkg.scripts[stage]
113112
} else {

0 commit comments

Comments
 (0)