Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix generated bin doesn't work #970

Merged
merged 2 commits into from
Jan 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ x

<!-- Your comment below this -->

- Fix generated binary - [@hellocore]
<!-- Your comment above this -->

# 9.2.9
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
"lint-staged": "^7.3.0",
"madge": "^3.2.0",
"nock": "^10.0.6",
"pkg": "^4.3.4",
"pkg": "^4.4.2",
"prettier": "^1.14.2",
"release-it": "^7.6.1",
"shx": "^0.3.2",
Expand Down
10 changes: 10 additions & 0 deletions source/ambient.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,13 @@ declare module "parse-git-config"
declare module "parse-github-url"
// Basically does one thing
declare module "override-require"

declare namespace NodeJS {
interface Process {
// https://github.com/zeit/pkg#snapshot-filesystem
pkg?: {
entrypoint: string
defaultEntrypoint: string
}
}
}
34 changes: 34 additions & 0 deletions source/commands/utils/_tests/dangerRunToRunnerCLI.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,37 @@ it("`danger pr --dangerfile 'myDanger file.ts'`", () => {
"myDanger file.ts",
])
})

describe("it can handle the command when running from pkg", () => {
beforeAll(() => {
process.pkg = {
defaultEntrypoint: "Hello",
entrypoint: "World",
}
})

afterAll(() => {
process.pkg = undefined
})

it("`./brew-distribution/danger /snapshot/danger-js/distribution/commands/danger-pr.js --dangerfile myDangerfile.ts`", () => {
/**
* The example of argv
* [ '/Users/core/Documents/project/danger-js/brew-distribution/danger',
* '/snapshot/danger-js/distribution/commands/danger-pr.js',
* 'https://bitbucket.org/foo/bar/pull-requests/381' ]
*/
expect(
dangerRunToRunnerCLI([
"./brew-distribution/danger",
"/snapshot/danger-js/distribution/commands/danger-pr.js",
"--dangerfile",
"myDangerfile.ts",
])
).toEqual(
"./brew-distribution/danger /snapshot/danger-js/distribution/commands/danger-runner.js --dangerfile myDangerfile.ts".split(
" "
)
)
})
})
2 changes: 1 addition & 1 deletion source/commands/utils/dangerRunToRunnerCLI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const dangerRunToRunnerCLI = (argv: string[]) => {

if (argv.length === 1) {
return ["danger", "runner"]
} else if (argv[0].includes("node")) {
} else if (argv[0].includes("node") || process.pkg != null) {
// convert
let newJSFile = argv[1]
usesProcessSeparationCommands.forEach(name => {
Expand Down
Loading