Skip to content

Commit f975f69

Browse files
committed
fix error-on-fail test
1 parent 67f929b commit f975f69

File tree

5 files changed

+14
-6
lines changed

5 files changed

+14
-6
lines changed

integration-tests/dev-only-patches/__snapshots__/dev-only-patches.test.ts.snap

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ patch-package finished with 1 error(s).
2323
END SNAPSHOT"
2424
`;
2525

26-
exports[`Test dev-only-patches: patch-package happily ignores slash because it's a dev dep 1`] = `
27-
"SNAPSHOT: patch-package happily ignores slash because it's a dev dep
26+
exports[`Test dev-only-patches: patch-package happily ignores slash on CI because it's a dev dep 1`] = `
27+
"SNAPSHOT: patch-package happily ignores slash on CI because it's a dev dep
2828
patch-package 0.0.0
2929
Applying patches...
3030

integration-tests/dev-only-patches/dev-only-patches.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ set -e
33

44
echo "set production mode"
55
export NODE_ENV=production
6+
export CI="true"
67

78
echo "add patch-package"
89
yarn add $1
910
alias patch-package=./node_modules/.bin/patch-package
1011

11-
echo "SNAPSHOT: patch-package happily ignores slash because it's a dev dep"
12+
echo "SNAPSHOT: patch-package happily ignores slash on CI because it's a dev dep"
1213
patch-package
1314
echo "END SNAPSHOT"
1415

integration-tests/error-on-fail/error-on-fail.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ yarn add $1
66
alias patch-package=./node_modules/.bin/patch-package
77

88
export NODE_ENV="development"
9-
export CI=""
9+
export CI="true"
1010

1111
(>&2 echo "SNAPSHOT: at dev time patch-package fails but returns 0")
1212
if ! patch-package;

integration-tests/runIntegrationTest.ts

+4
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ export function runIntegrationTest({
4040
{
4141
cwd: tmpDir.name,
4242
throwOnError: false,
43+
env: {
44+
...process.env,
45+
PATCH_PACKAGE_INTEGRATION_TEST: "1",
46+
},
4347
shell: true,
4448
},
4549
)

src/index.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,13 @@ if (argv.version || argv.v) {
7575
} else {
7676
console.log("Applying patches...")
7777
const reverse = !!argv["reverse"]
78-
// don't want to exit(1) on postinsall locally.
78+
// don't want to exit(1) on postinstall locally.
7979
// see https://github.com/ds300/patch-package/issues/86
8080
const shouldExitWithError =
81-
!!argv["error-on-fail"] || isCI || process.env.NODE_ENV === "test"
81+
!!argv["error-on-fail"] ||
82+
(process.env.NODE_ENV === "production" && isCI) ||
83+
(isCI && !process.env.PATCH_PACKAGE_INTEGRATION_TEST) ||
84+
process.env.NODE_ENV === "test"
8285

8386
const shouldExitWithWarning = !!argv["error-on-warn"]
8487

0 commit comments

Comments
 (0)