Skip to content

Commit

Permalink
Update to commander 9.x types
Browse files Browse the repository at this point in the history
  • Loading branch information
glensc committed Mar 22, 2022
1 parent 3918872 commit 56f0100
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
6 changes: 3 additions & 3 deletions source/commands/utils/sharedDangerfileArgs.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import program from "commander"
import { Command } from "commander"
import chalk from "chalk"

process.on("unhandledRejection", function(reason: string, _p: any) {
process.on("unhandledRejection", function (reason: string, _p: any) {
console.log(chalk.red("Error: "), reason)
process.exitCode = 1
})

export interface SharedCLI extends program.CommanderStatic {
export interface SharedCLI extends Command {
/** Should we be posting as much info as possible? */
verbose: boolean
/** Output to STDOUT instead of leaving a comment */
Expand Down
6 changes: 3 additions & 3 deletions source/runner/dslGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { DangerDSLJSONType } from "../dsl/DangerDSL"
import { CliArgs } from "../dsl/cli-args"
import { CISource } from "../ci_source/ci_source"
import { emptyGitJSON } from "../platforms/github/GitHubGit"
import { CommanderStatic } from "commander"
import { Command } from "commander"

export const jsonDSLGenerator = async (
platform: Platform,
source: CISource,
program: CommanderStatic
program: Command
): Promise<DangerDSLJSONType> => {
const useSimpleDSL = platform.getPlatformReviewSimpleRepresentation && source.useEventDSL

Expand All @@ -27,7 +27,7 @@ export const jsonDSLGenerator = async (
id: program.id,
textOnly: program.textOnly,
verbose: program.verbose,
staging: program.staging
staging: program.staging,
}

const dslPlatformName = jsonDSLPlatformName(platform)
Expand Down
10 changes: 3 additions & 7 deletions source/runner/jsonToContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { jsonToDSL } from "./jsonToDSL"
import { contextForDanger, DangerContext } from "./Dangerfile"
import { DangerDSLJSON } from "./dangerDSLJSON"
import { CISource } from "../ci_source/ci_source"
import { CommanderStatic } from "commander"
import { Command } from "commander"

/**
* Reads in the JSON string converts to a dsl object and gets the change context
Expand All @@ -12,12 +12,8 @@ import { CommanderStatic } from "commander"
* @param program {any} commander
* @returns {Promise<DangerContext>} context for danger
*/
export async function jsonToContext(
JSONString: string,
program: CommanderStatic,
source: CISource
): Promise<DangerContext> {
const dslJSON = { danger: new DangerDSLJSON(JSONString, (program as any) as CliArgs) }
export async function jsonToContext(JSONString: string, program: Command, source: CISource): Promise<DangerContext> {
const dslJSON = { danger: new DangerDSLJSON(JSONString, program as any as CliArgs) }
const dsl = await jsonToDSL(dslJSON.danger, source)
return contextForDanger(dsl)
}

0 comments on commit 56f0100

Please sign in to comment.