Skip to content

Commit

Permalink
Merge pull request #1378 from a-riva/fix/support-commands-without-js-…
Browse files Browse the repository at this point in the history
…extension

Fix commands run without the .js extension
  • Loading branch information
orta authored Apr 11, 2023
2 parents 12eea7f + 2f3e3b9 commit c62bff7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
16 changes: 15 additions & 1 deletion source/commands/utils/_tests/dangerRunToRunnerCLI.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,25 @@ it("should properly replace `danger-runner` in a path that contains an additiona
dangerRunToRunnerCLI([
"/Users/Mike.DiDomizio/.nvm/versions/node/v16.13.2/bin/node",
"/Users/Mike.DiDomizio/projects/test/danger-project-setup/node_modules/danger/distribution/commands/danger-pr.js",
"https://github.com/facebook/react/pull/11865"
"https://github.com/facebook/react/pull/11865",
])
).toEqual([
"/Users/Mike.DiDomizio/.nvm/versions/node/v16.13.2/bin/node",
"/Users/Mike.DiDomizio/projects/test/danger-project-setup/node_modules/danger/distribution/commands/danger-runner.js",
"https://github.com/facebook/react/pull/11865",
])
})

it("should properly replace `danger-runner` in a path that contains an additional `danger-pr` in it even without the .js extension", () => {
expect(
dangerRunToRunnerCLI([
"/Users/Mike.DiDomizio/.nvm/versions/node/v16.13.2/bin/node",
"/Users/Mike.DiDomizio/projects/test/danger-project-setup/node_modules/danger/distribution/commands/danger-pr",
"https://github.com/facebook/react/pull/11865",
])
).toEqual([
"/Users/Mike.DiDomizio/.nvm/versions/node/v16.13.2/bin/node",
"/Users/Mike.DiDomizio/projects/test/danger-project-setup/node_modules/danger/distribution/commands/danger-runner",
"https://github.com/facebook/react/pull/11865",
])
})
4 changes: 2 additions & 2 deletions source/commands/utils/dangerRunToRunnerCLI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ const dangerRunToRunnerCLI = (argv: string[]) => {
// convert
let newJSFile = argv[1]
usesProcessSeparationCommands.forEach((name) => {
const re = new RegExp(`danger-${name}\.js$`)
newJSFile = newJSFile.replace(re, "danger-runner.js")
const re = new RegExp(`danger-${name}(\.js)?$`)
newJSFile = newJSFile.replace(re, "danger-runner$1")
})

// Support re-routing internally in npx for danger-ts
Expand Down

0 comments on commit c62bff7

Please sign in to comment.