Skip to content

Commit 0aef3ba

Browse files
committed
add support for PATCH_PACKAGE_IGNORE_MISSING env var
1 parent d16cfce commit 0aef3ba

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

integration-tests/ignore-missing/__snapshots__/ignore-missing.test.ts.snap

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,12 @@ [email protected]
1616
Skipping missing [email protected]
1717
END SNAPSHOT"
1818
`;
19+
20+
exports[`Test ignore-missing: setting PATCH_PACKAGE_IGNORE_MISSING=1 forces patch-package to return 0 1`] = `
21+
"SNAPSHOT: setting PATCH_PACKAGE_IGNORE_MISSING=1 forces patch-package to return 0
22+
patch-package 0.0.0
23+
Applying patches...
24+
25+
Skipping missing [email protected]
26+
END SNAPSHOT"
27+
`;

integration-tests/ignore-missing/ignore-missing.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,8 @@ fi
1515
echo "SNAPSHOT: adding --ignore-missing forces patch-package to return 0"
1616
patch-package --ignore-missing;
1717
echo "END SNAPSHOT"
18+
19+
export PATCH_PACKAGE_IGNORE_MISSING=1
20+
echo "SNAPSHOT: setting PATCH_PACKAGE_IGNORE_MISSING=1 forces patch-package to return 0"
21+
patch-package;
22+
echo "END SNAPSHOT"

src/index.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ if (argv.version || argv.v) {
8686

8787
const shouldExitWithWarning = !!argv["error-on-warn"]
8888

89-
const ignoreMissing = !!argv["ignore-missing"]
89+
const ignoreMissing =
90+
!!argv["ignore-missing"] || !!process.env.PATCH_PACKAGE_IGNORE_MISSING
9091

9192
applyPatchesForApp({
9293
appPath,
@@ -157,6 +158,13 @@ Usage:
157158
This is useful when working with monorepos and wanting to install sub-packages
158159
separately from the root package, with pruned dependencies.
159160
161+
This option is can also be set via the environment variable
162+
PATCH_PACKAGE_IGNORE_MISSING=1. Setting this env variable during the deployment
163+
build process is recommended instead of using the --ignore-missing command option
164+
when we want to ignore missing packages during deployment (of a monorepo with
165+
pruned dependencies), but ensure we fail loudly during development if any
166+
dependencies are moved or removed without updating the patches accordingly.
167+
160168
See https://github.com/ds300/patch-package/issues/339 for background.
161169
162170

0 commit comments

Comments
 (0)