Skip to content

Commit

Permalink
Fix commands run on paths with danger-pr in them
Browse files Browse the repository at this point in the history
  • Loading branch information
mikedidomizio committed Apr 8, 2023
1 parent baec67f commit ad73816
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
14 changes: 14 additions & 0 deletions source/commands/utils/_tests/dangerRunToRunnerCLI.test.ts
Expand Up @@ -116,3 +116,17 @@ describe("it can handle the command when running from pkg", () => {
)
})
})

it("should properly replace `danger-runner` in a path that contains an additional `danger-pr` in it", () => {
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.js",
"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",
])
})
3 changes: 2 additions & 1 deletion source/commands/utils/dangerRunToRunnerCLI.ts
Expand Up @@ -15,7 +15,8 @@ const dangerRunToRunnerCLI = (argv: string[]) => {
// convert
let newJSFile = argv[1]
usesProcessSeparationCommands.forEach((name) => {
newJSFile = newJSFile.replace("danger-" + name, "danger-runner")
const re = new RegExp(`danger-${name}\.js$`)
newJSFile = newJSFile.replace(re, "danger-runner.js")
})

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

0 comments on commit ad73816

Please sign in to comment.