Skip to content

Commit d9ae5a3

Browse files
authored
Merge pull request #112 from ds300/fix/fail-only-on-ci
use is-ci to fail postinstall on CI but not locally
2 parents 84e027b + d1f24a9 commit d9ae5a3

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,11 @@
6464
"typescript": "^3.2.2"
6565
},
6666
"dependencies": {
67+
"@types/is-ci": "^1.1.0",
6768
"chalk": "^1.1.3",
6869
"cross-spawn": "^5.1.0",
6970
"fs-extra": "^4.0.1",
71+
"is-ci": "^2.0.0",
7072
"klaw-sync": "^4.0.0",
7173
"minimist": "^1.2.0",
7274
"rimraf": "^2.6.2",

src/applyPatches.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ import { posix } from "path"
77
import { getPackageDetailsFromPatchFilename } from "./PackageDetails"
88
import { parsePatchFile } from "./patch/parse"
99
import { reversePatch } from "./patch/reverse"
10+
import isCi from "is-ci"
11+
12+
// don't want to exit(1) on postinsall locally.
13+
// see https://github.com/ds300/patch-package/issues/86
14+
const shouldExitPostinstallWithError = isCi || process.env.NODE_ENV === "test"
1015

1116
function findPatchFiles(patchesDirectory: string): string[] {
1217
if (!existsSync(patchesDirectory)) {
@@ -49,7 +54,7 @@ export const applyPatchesForApp = (
4954

5055
if (files.length === 0) {
5156
console.error(red("No patch files found"))
52-
process.exit(1)
57+
process.exit(shouldExitPostinstallWithError ? 1 : 0)
5358
}
5459

5560
files.forEach(filename => {
@@ -106,7 +111,7 @@ export const applyPatchesForApp = (
106111
pathSpecifier,
107112
})
108113
}
109-
process.exit(1)
114+
process.exit(shouldExitPostinstallWithError ? 1 : 0)
110115
}
111116
})
112117
}

yarn.lock

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@
3232
dependencies:
3333
"@types/node" "*"
3434

35+
"@types/is-ci@^1.1.0":
36+
version "1.1.0"
37+
resolved "https://registry.yarnpkg.com/@types/is-ci/-/is-ci-1.1.0.tgz#583c5fbfcc461be9971106b9558930d67df49227"
38+
integrity sha512-NbyqP5D4hwl5UWnnW4Cz0gIRjhecgx/9OApcCIpp4+tjqjROGf/NBcKKDfbI3YFBTTkD3JBshiNSv5V7VoVJJg==
39+
3540
"@types/jest@^23.3.12":
3641
version "23.3.12"
3742
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-23.3.12.tgz#7e0ced251fa94c3bc2d1023d4b84b2992fa06376"
@@ -707,6 +712,11 @@ ci-info@^1.0.0:
707712
version "1.0.0"
708713
resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-1.0.0.tgz#dc5285f2b4e251821683681c381c3388f46ec534"
709714

715+
ci-info@^2.0.0:
716+
version "2.0.0"
717+
resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-2.0.0.tgz#67a9e964be31a51e15e5010d58e6f12834002f46"
718+
integrity sha512-5tK7EtrZ0N+OLFMthtqOj4fI2Jeb88C4CAZPu25LDVUgXJ0A3Js4PMGqrn0JU1W0Mh1/Z8wZzYPxqUrXeBboCQ==
719+
710720
class-utils@^0.3.5:
711721
version "0.3.6"
712722
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:
18461856
dependencies:
18471857
ci-info "^1.0.0"
18481858

1859+
is-ci@^2.0.0:
1860+
version "2.0.0"
1861+
resolved "https://registry.yarnpkg.com/is-ci/-/is-ci-2.0.0.tgz#6bc6334181810e04b5c22b3d589fdca55026404c"
1862+
integrity sha512-YfJT7rkpQB0updsdHLGWrvhBJfcfzNNawYDNIyQXJz0IViGf75O8EBPKSdvw2rF+LGCsX4FZ8tcr3b19LcZq4w==
1863+
dependencies:
1864+
ci-info "^2.0.0"
1865+
18491866
is-data-descriptor@^0.1.4:
18501867
version "0.1.4"
18511868
resolved "https://registry.yarnpkg.com/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz#0b5ee648388e2c860282e793f1856fec3f301b56"

0 commit comments

Comments
 (0)