Skip to content

Commit

Permalink
Merge pull request #1375 from mikedidomizio/support-projects-with-dan…
Browse files Browse the repository at this point in the history
…ger-in-project-title

Fix commands run on paths with danger-pr in them
  • Loading branch information
orta authored Apr 8, 2023
2 parents baec67f + ad73816 commit cffbb1d
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 cffbb1d

Please sign in to comment.