Skip to content

Commit

Permalink
Remove 'publish' script if it's 'clean-publish'
Browse files Browse the repository at this point in the history
If someone would try setting up 'clean-publish' as told in the docs,
one would get an endless loop when trying to call 'npm publish'. This
is because 'publish' scripts were not removed but called after cleanup,
which would then cause the program to loop endlessly and creates an
infinite tree of temporary directories.

After this commit, 'clean-publish' will check if the 'publish' script
contains call to 'clean-publish' and, if that's the case, remove this
script.

Closes #134
  • Loading branch information
kytta committed Dec 4, 2021
1 parent c0f693d commit abe0eac
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions core.js
Expand Up @@ -46,6 +46,14 @@ export function clearPackageJSON(
cleanPackageJSON.scripts = filterObjectByKey(packageJson.scripts, script =>
NPM_SCRIPTS.includes(script)
)

if (
cleanPackageJSON.scripts.publish &&
cleanPackageJSON.scripts.publish.startsWith('clean-publish')
) {
// "custom" publish script is actually calling clean-publish
delete cleanPackageJSON.scripts.publish
}
}

if (isObject(packageJson.exports) && !ignoreFields.includes('exports')) {
Expand Down

0 comments on commit abe0eac

Please sign in to comment.