diff --git a/package.json b/package.json index 549579ab..c6d20cc3 100644 --- a/package.json +++ b/package.json @@ -64,9 +64,11 @@ "typescript": "^3.2.2" }, "dependencies": { + "@types/is-ci": "^1.1.0", "chalk": "^1.1.3", "cross-spawn": "^5.1.0", "fs-extra": "^4.0.1", + "is-ci": "^2.0.0", "klaw-sync": "^4.0.0", "minimist": "^1.2.0", "rimraf": "^2.6.2", diff --git a/src/applyPatches.ts b/src/applyPatches.ts index e71f7c59..352e00a3 100644 --- a/src/applyPatches.ts +++ b/src/applyPatches.ts @@ -7,6 +7,11 @@ import { posix } from "path" import { getPackageDetailsFromPatchFilename } from "./PackageDetails" import { parsePatchFile } from "./patch/parse" import { reversePatch } from "./patch/reverse" +import isCi from "is-ci" + +// don't want to exit(1) on postinsall locally. +// see https://github.com/ds300/patch-package/issues/86 +const shouldExitPostinstallWithError = isCi || process.env.NODE_ENV === "test" function findPatchFiles(patchesDirectory: string): string[] { if (!existsSync(patchesDirectory)) { @@ -49,7 +54,7 @@ export const applyPatchesForApp = ( if (files.length === 0) { console.error(red("No patch files found")) - process.exit(1) + process.exit(shouldExitPostinstallWithError ? 1 : 0) } files.forEach(filename => { @@ -106,7 +111,7 @@ export const applyPatchesForApp = ( pathSpecifier, }) } - process.exit(1) + process.exit(shouldExitPostinstallWithError ? 1 : 0) } }) } diff --git a/yarn.lock b/yarn.lock index ffaa4ed9..b36a6a60 100644 --- a/yarn.lock +++ b/yarn.lock @@ -32,6 +32,11 @@ dependencies: "@types/node" "*" +"@types/is-ci@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@types/is-ci/-/is-ci-1.1.0.tgz#583c5fbfcc461be9971106b9558930d67df49227" + integrity sha512-NbyqP5D4hwl5UWnnW4Cz0gIRjhecgx/9OApcCIpp4+tjqjROGf/NBcKKDfbI3YFBTTkD3JBshiNSv5V7VoVJJg== + "@types/jest@^23.3.12": version "23.3.12" resolved "https://registry.yarnpkg.com/@types/jest/-/jest-23.3.12.tgz#7e0ced251fa94c3bc2d1023d4b84b2992fa06376" @@ -707,6 +712,11 @@ ci-info@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-1.0.0.tgz#dc5285f2b4e251821683681c381c3388f46ec534" +ci-info@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-2.0.0.tgz#67a9e964be31a51e15e5010d58e6f12834002f46" + integrity sha512-5tK7EtrZ0N+OLFMthtqOj4fI2Jeb88C4CAZPu25LDVUgXJ0A3Js4PMGqrn0JU1W0Mh1/Z8wZzYPxqUrXeBboCQ== + class-utils@^0.3.5: version "0.3.6" resolved "https://registry.yarnpkg.com/class-utils/-/class-utils-0.3.6.tgz#f93369ae8b9a7ce02fd41faad0ca83033190c463" @@ -1846,6 +1856,13 @@ is-ci@^1.0.10, is-ci@^1.0.9: dependencies: ci-info "^1.0.0" +is-ci@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/is-ci/-/is-ci-2.0.0.tgz#6bc6334181810e04b5c22b3d589fdca55026404c" + integrity sha512-YfJT7rkpQB0updsdHLGWrvhBJfcfzNNawYDNIyQXJz0IViGf75O8EBPKSdvw2rF+LGCsX4FZ8tcr3b19LcZq4w== + dependencies: + ci-info "^2.0.0" + is-data-descriptor@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz#0b5ee648388e2c860282e793f1856fec3f301b56"