What / Why
Currently running npm install fetches and installs a package as-is. However it would be more flexible to be able to specify a patch to apply at installation time to customize a package. One use case is to modify the package source to remove donation banners in install logs.
This is complementary to -- and more general than -- #80.
When
At install time, with the presence of a new flag.
How
Add a --patch /path/to/my.patch option to npm install. NPM would then fetch the source as usual, run patch -p0 < /path/to/my.patch to apply the customization, and continue with the normal installation process.
Example
Suppose you want to install core-js without its donation banner breaking your continuous integration. You can already use npm install --loglevel silent, but this will silence other potentially useful messages.
Instead, the user could create a patch file, e.g. nobanner.patch:
--- packages/core-js/postinstall.js
+++ packages/core-js/postinstall.js
@@ -52,5 +52,3 @@
// eslint-disable-next-line no-console,no-control-regex
console.log(COLOR ? BANNER : BANNER.replace(/\u001B\[\d+m/g, ''));
}
-
-if (isBannerRequired()) showBanner();
Then, using the proposed feature, run:
npm install --patch nobanner.patch core-js
What / Why
Currently running
npm installfetches and installs a package as-is. However it would be more flexible to be able to specify a patch to apply at installation time to customize a package. One use case is to modify the package source to remove donation banners in install logs.This is complementary to -- and more general than -- #80.
When
At install time, with the presence of a new flag.
How
Add a
--patch /path/to/my.patchoption tonpm install. NPM would then fetch the source as usual, runpatch -p0 < /path/to/my.patchto apply the customization, and continue with the normal installation process.Example
Suppose you want to install core-js without its donation banner breaking your continuous integration. You can already use
npm install --loglevel silent, but this will silence other potentially useful messages.Instead, the user could create a patch file, e.g.
nobanner.patch:Then, using the proposed feature, run: