Skip to content

Commit 2f13081

Browse files
authored
Merge pull request #970 from HelloCore/fix/generated-bin
Fix generated bin doesn't work
2 parents dab0e63 + 3bbcc44 commit 2f13081

File tree

6 files changed

+472
-103
lines changed

6 files changed

+472
-103
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ x
1515

1616
<!-- Your comment below this -->
1717

18+
- Fix generated binary - [@hellocore]
1819
<!-- Your comment above this -->
1920

2021
# 9.2.9

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@
122122
"lint-staged": "^7.3.0",
123123
"madge": "^3.2.0",
124124
"nock": "^10.0.6",
125-
"pkg": "^4.3.4",
125+
"pkg": "^4.4.2",
126126
"prettier": "^1.14.2",
127127
"release-it": "^7.6.1",
128128
"shx": "^0.3.2",

source/ambient.d.ts

+10
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,13 @@ declare module "parse-git-config"
4545
declare module "parse-github-url"
4646
// Basically does one thing
4747
declare module "override-require"
48+
49+
declare namespace NodeJS {
50+
interface Process {
51+
// https://github.com/zeit/pkg#snapshot-filesystem
52+
pkg?: {
53+
entrypoint: string
54+
defaultEntrypoint: string
55+
}
56+
}
57+
}

source/commands/utils/_tests/dangerRunToRunnerCLI.test.ts

+34
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,37 @@ it("`danger pr --dangerfile 'myDanger file.ts'`", () => {
4848
"myDanger file.ts",
4949
])
5050
})
51+
52+
describe("it can handle the command when running from pkg", () => {
53+
beforeAll(() => {
54+
process.pkg = {
55+
defaultEntrypoint: "Hello",
56+
entrypoint: "World",
57+
}
58+
})
59+
60+
afterAll(() => {
61+
process.pkg = undefined
62+
})
63+
64+
it("`./brew-distribution/danger /snapshot/danger-js/distribution/commands/danger-pr.js --dangerfile myDangerfile.ts`", () => {
65+
/**
66+
* The example of argv
67+
* [ '/Users/core/Documents/project/danger-js/brew-distribution/danger',
68+
* '/snapshot/danger-js/distribution/commands/danger-pr.js',
69+
* 'https://bitbucket.org/foo/bar/pull-requests/381' ]
70+
*/
71+
expect(
72+
dangerRunToRunnerCLI([
73+
"./brew-distribution/danger",
74+
"/snapshot/danger-js/distribution/commands/danger-pr.js",
75+
"--dangerfile",
76+
"myDangerfile.ts",
77+
])
78+
).toEqual(
79+
"./brew-distribution/danger /snapshot/danger-js/distribution/commands/danger-runner.js --dangerfile myDangerfile.ts".split(
80+
" "
81+
)
82+
)
83+
})
84+
})

source/commands/utils/dangerRunToRunnerCLI.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const dangerRunToRunnerCLI = (argv: string[]) => {
99

1010
if (argv.length === 1) {
1111
return ["danger", "runner"]
12-
} else if (argv[0].includes("node")) {
12+
} else if (argv[0].includes("node") || process.pkg != null) {
1313
// convert
1414
let newJSFile = argv[1]
1515
usesProcessSeparationCommands.forEach(name => {

0 commit comments

Comments
 (0)