Skip to content

Commit

Permalink
Merge pull request #970 from HelloCore/fix/generated-bin
Browse files Browse the repository at this point in the history
Fix generated bin doesn't work
  • Loading branch information
orta committed Jan 5, 2020
2 parents dab0e63 + 3bbcc44 commit 2f13081
Show file tree
Hide file tree
Showing 6 changed files with 472 additions and 103 deletions.
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

0 comments on commit 2f13081

Please sign in to comment.