Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli: use kebab-case for --retry-tag-filter arg #1293

Merged
merged 14 commits into from
Mar 17, 2020
Prev Previous commit
Next Next commit
rework again, do linting in argv parser
davidjgoss committed Mar 13, 2020
commit 2fdd09467b96a4d94733762455cfa7b629e2a700
1 change: 1 addition & 0 deletions features/retry.feature
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@ Feature: Retry flaky tests
"""
And it fails

@spawn
Scenario: running Cucumber JS with --retryTagFilter in camel case will result in a warning
Given a file named "features/a.feature" with:
"""
1 change: 0 additions & 1 deletion features/support/world.ts
Original file line number Diff line number Diff line change
@@ -65,7 +65,6 @@ export class World {
argv: args,
cwd,
stdout,
stderr,
})
let error: any
try {
8 changes: 8 additions & 0 deletions src/cli/argv_parser.ts
Original file line number Diff line number Diff line change
@@ -224,6 +224,14 @@ const ArgvParser = {
args: program.args,
}
},

lint(fullArgv: string[]): void {
if (fullArgv.includes('--retryTagFilter')) {
console.warn(
'the argument --retryTagFilter is deprecated and will be removed in a future release; please use --retry-tag-filter'
)
}
},
}

export default ArgvParser
1 change: 1 addition & 0 deletions src/cli/configuration_builder.ts
Original file line number Diff line number Diff line change
@@ -55,6 +55,7 @@ export default class ConfigurationBuilder {
constructor({ argv, cwd }: INewConfigurationBuilderOptions) {
this.cwd = cwd

ArgvParser.lint(argv)
const parsedArgv = ArgvParser.parse(argv)
this.args = parsedArgv.args
this.options = parsedArgv.options
16 changes: 1 addition & 15 deletions src/cli/index.ts
Original file line number Diff line number Diff line change
@@ -22,7 +22,6 @@ import { doesNotHaveValue } from '../value_checker'
import Gherkin from 'gherkin'
import { ISupportCodeLibrary } from '../support_code_library_builder/types'
import { IParsedArgvFormatOptions } from './argv_parser'
import { Console } from 'console'
import { WriteStream } from 'fs'

const { incrementing, uuid } = IdGenerator
@@ -50,45 +49,32 @@ export default class Cli {
private readonly argv: string[]
private readonly cwd: string
private readonly stdout: IFormatterStream
private readonly console: Console

constructor({
argv,
cwd,
stdout,
stderr,
}: {
argv: string[]
cwd: string
stdout: IFormatterStream
stderr: IFormatterStream
}) {
this.argv = argv
this.cwd = cwd
this.stdout = stdout
this.console = new Console({ stdout, stderr })
}

async getConfiguration(): Promise<IConfiguration> {
const fullArgv = await getExpandedArgv({
argv: this.argv,
cwd: this.cwd,
})
this.lintArgv(fullArgv)
return ConfigurationBuilder.build({
argv: fullArgv,
cwd: this.cwd,
})
}

private lintArgv(fullArgv: string[]): void {
if (fullArgv.includes('--retryTagFilter')) {
this.console.warn(
'the argument --retryTagFilter is deprecated and will be removed in a future release; please use --retry-tag-filter'
)
}
}

async initializeFormatters({
eventBroadcaster,
eventDataCollector,
@@ -118,7 +104,7 @@ export default class Cli {
}
if (type === 'progress-bar' && !(stream as TtyWriteStream).isTTY) {
const outputToName = outputTo === '' ? 'stdout' : outputTo
this.console.warn(
console.warn(
`Cannot use 'progress-bar' formatter for output to '${outputToName}' as not a TTY. Switching to 'progress' formatter.`
)
type = 'progress'
1 change: 0 additions & 1 deletion src/cli/run.ts
Original file line number Diff line number Diff line change
@@ -12,7 +12,6 @@ export default async function run(): Promise<void> {
argv: process.argv,
cwd,
stdout: process.stdout,
stderr: process.stderr,
})

let result: ICliRunResult