-
-
Notifications
You must be signed in to change notification settings - Fork 368
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert danger run to use danger process under the hood
- Loading branch information
Showing
9 changed files
with
107 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
#!/usr/bin/env ruby | ||
|
||
str = STDIN.tty? ? 'Cannot read from STDIN' : $stdin.read | ||
str = STDIN.tty? ? "Cannot read from STDIN" : $stdin.read | ||
exit(1) unless str | ||
|
||
# Have a dumb fake response | ||
require 'json' | ||
require "json" | ||
results = { fails: [], warnings: [], messages: [], markdowns: [] }.to_json | ||
|
||
STDOUT.write(results) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import dangerRunToRunnerCLI from "../dangerRunToRunnerCLI" | ||
|
||
describe("it can handle the command", () => { | ||
it("`danger`", () => { | ||
expect(dangerRunToRunnerCLI(["danger"])).toEqual("danger runner") | ||
}) | ||
|
||
it("`danger --dangerfile myDangerfile.ts`", () => { | ||
expect(dangerRunToRunnerCLI(["danger", "--dangerfile", "myDangerfile.ts"])).toEqual( | ||
"danger runner --dangerfile myDangerfile.ts".split(" ") | ||
) | ||
}) | ||
|
||
it("`danger run`", () => { | ||
expect(dangerRunToRunnerCLI(["danger", "run"])).toEqual("danger runner".split(" ")) | ||
}) | ||
|
||
it("`danger run --dangerfile myDangerfile.ts`", () => { | ||
expect(dangerRunToRunnerCLI(["danger", "run", "--dangerfile", "myDangerfile.ts"])).toEqual( | ||
"danger runner --dangerfile myDangerfile.ts".split(" ") | ||
) | ||
}) | ||
|
||
it("`node distribution/commands/danger-run.js`", () => { | ||
expect(dangerRunToRunnerCLI(["node", "distribution/commands/danger-run.js"])).toEqual( | ||
"node distribution/commands/danger-runner.js".split(" ") | ||
) | ||
}) | ||
|
||
it("`node distribution/commands/danger-run.js --dangerfile myDangerfile.ts`", () => { | ||
expect( | ||
dangerRunToRunnerCLI(["node", "distribution/commands/danger-run.js", "--dangerfile", "myDangerfile.ts"]) | ||
).toEqual("node distribution/commands/danger-runner.js --dangerfile myDangerfile.ts".split(" ")) | ||
}) | ||
}) | ||
|
||
it("`node distribution/commands/danger-run.js --dangerfile 'myDanger file.ts'`", () => { | ||
expect( | ||
dangerRunToRunnerCLI(["node", "distribution/commands/danger-run.js", "--dangerfile", "myDanger file.ts"]) | ||
).toEqual(["node", "distribution/commands/danger-runner.js", "--dangerfile", "myDanger file.ts"]) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const dangerRunToRunnerCLI = (argv: string[]) => { | ||
let newCommand = [] | ||
newCommand.push(argv[0]) | ||
|
||
// e.g. node --inspect distribution/commands/danger-run.js --dangerfile myDangerfile.ts | ||
if (argv.length === 1) { | ||
return ["danger", "runner"] | ||
} else if (argv[0].includes("node")) { | ||
newCommand.push(argv[1].replace("-run", "-runner")) | ||
for (let index = 2; index < argv.length; index++) { | ||
newCommand.push(argv[index]) | ||
} | ||
} else { | ||
// e.g. danger --dangerfile | ||
// if you do `danger run` start looking at args later | ||
newCommand.push("runner") | ||
let index = argv[1] === "run" ? 2 : 1 | ||
for (; index < argv.length; index++) { | ||
newCommand.push(argv[index]) | ||
} | ||
} | ||
|
||
return newCommand | ||
} | ||
|
||
export default dangerRunToRunnerCLI |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters