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

fix: validate ncu-ci args #411

Merged
merged 1 commit into from
May 14, 2020
Merged

Conversation

codebytere
Copy link
Member

Closes #393.

Not a perfect solution, but this validates that the user didn't type something like:

ncu-ci --markdown url https://ci.nodejs.org/job/node-test-pull-request/29714/

and throws a helpful error if that's the case.

cc @mmarchini @joyeecheung

@codebytere codebytere force-pushed the validate-ncu-ci-args branch 2 times, most recently from 425fab1 to 6408ccd Compare May 6, 2020 16:30
@codebytere codebytere force-pushed the validate-ncu-ci-args branch from 6408ccd to 4cba1ff Compare May 6, 2020 16:41
@codecov
Copy link

codecov bot commented May 6, 2020

Codecov Report

Merging #411 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #411   +/-   ##
=======================================
  Coverage   76.28%   76.28%           
=======================================
  Files          21       21           
  Lines        1480     1480           
=======================================
  Hits         1129     1129           
  Misses        351      351           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 255e660...4cba1ff. Read the comment docs.

Comment on lines +133 to 140
}).check(argv => {
if (argv.markdown && commandKeys.includes(argv.markdown)) {
throw new Error('--markdown <path> did not specify a valid path');
} else if (argv.json && commandKeys.includes(argv.json)) {
throw new Error('--json <path> did not specify a valid path');
}
return true;
})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can use requiresArg: true in the option's definition instead of manual validation

@codebytere
Copy link
Member Author

codebytere commented May 12, 2020

@targos i tried that initially but it didn't seem to have the desired effect - it just silently fails as before:

node-core-utils on git:validate-ncu-ci-args ❯ bin/ncu-ci --markdown url https://ci.nodejs.org/job/node-test-pull-request/29714/
node-core-utils on git:validate-ncu-ci-args ❯

if i specify:

.option('json <path>', {
    type: 'string',
    requiresArg: true,
    describe: 'Write the results as json to <path>'
  })
  .option('markdown <path>', {
    type: 'string',
    requiresArg: true,
    describe: 'Write the results as markdown to <path>'
  })

with no manual validation

Looks like there might be a bug: yargs/yargs#1041

@codebytere codebytere requested a review from targos May 13, 2020 20:04
@codebytere codebytere merged commit dfe7adf into nodejs:master May 14, 2020
@codebytere codebytere deleted the validate-ncu-ci-args branch May 14, 2020 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ncu-ci flags will fail silently if no value is passed
2 participants