Skip to content

Commit

Permalink
fix error-on-fail test
Browse files Browse the repository at this point in the history
  • Loading branch information
ds300 committed Apr 25, 2023
1 parent 67f929b commit f975f69
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ patch-package finished with 1 error(s).
END SNAPSHOT"
`;

exports[`Test dev-only-patches: patch-package happily ignores slash because it's a dev dep 1`] = `
"SNAPSHOT: patch-package happily ignores slash because it's a dev dep
exports[`Test dev-only-patches: patch-package happily ignores slash on CI because it's a dev dep 1`] = `
"SNAPSHOT: patch-package happily ignores slash on CI because it's a dev dep
patch-package 0.0.0
Applying patches...
[email protected]
Expand Down
3 changes: 2 additions & 1 deletion integration-tests/dev-only-patches/dev-only-patches.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ set -e

echo "set production mode"
export NODE_ENV=production
export CI="true"

echo "add patch-package"
yarn add $1
alias patch-package=./node_modules/.bin/patch-package

echo "SNAPSHOT: patch-package happily ignores slash because it's a dev dep"
echo "SNAPSHOT: patch-package happily ignores slash on CI because it's a dev dep"
patch-package
echo "END SNAPSHOT"

Expand Down
2 changes: 1 addition & 1 deletion integration-tests/error-on-fail/error-on-fail.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ yarn add $1
alias patch-package=./node_modules/.bin/patch-package

export NODE_ENV="development"
export CI=""
export CI="true"

(>&2 echo "SNAPSHOT: at dev time patch-package fails but returns 0")
if ! patch-package;
Expand Down
4 changes: 4 additions & 0 deletions integration-tests/runIntegrationTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ export function runIntegrationTest({
{
cwd: tmpDir.name,
throwOnError: false,
env: {
...process.env,
PATCH_PACKAGE_INTEGRATION_TEST: "1",
},
shell: true,
},
)
Expand Down
7 changes: 5 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,13 @@ if (argv.version || argv.v) {
} else {
console.log("Applying patches...")
const reverse = !!argv["reverse"]
// don't want to exit(1) on postinsall locally.
// don't want to exit(1) on postinstall locally.
// see https://github.com/ds300/patch-package/issues/86
const shouldExitWithError =
!!argv["error-on-fail"] || isCI || process.env.NODE_ENV === "test"
!!argv["error-on-fail"] ||
(process.env.NODE_ENV === "production" && isCI) ||
(isCI && !process.env.PATCH_PACKAGE_INTEGRATION_TEST) ||
process.env.NODE_ENV === "test"

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

Expand Down

0 comments on commit f975f69

Please sign in to comment.