Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Use @istanbuljs/schema for yargs setup
BREAKING CHANGE: The `flow` and `jsx` parser plugins are no longer enabled by default.
- Loading branch information
1 parent
96b60b8
commit b20fb39
Showing
12 changed files
with
83 additions
and
480 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 was deleted.
Oops, something went wrong.
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,47 @@ | ||
'use strict' | ||
|
||
const decamelize = require('decamelize') | ||
const schema = require('@istanbuljs/schema') | ||
|
||
module.exports = { | ||
setupOptions (yargs, command, cwd) { | ||
Object.entries(schema.nyc.properties).forEach(([name, setup]) => { | ||
const option = { | ||
description: setup.description, | ||
default: setup.default, | ||
type: setup.type | ||
} | ||
|
||
if (name === 'cwd') { | ||
if (command !== null) { | ||
return | ||
} | ||
|
||
option.default = cwd | ||
option.global = true | ||
} | ||
|
||
if (option.type === 'array') { | ||
option.type = 'string' | ||
} | ||
|
||
if ('nycAlias' in setup) { | ||
option.alias = setup.nycAlias | ||
} | ||
|
||
const optionName = decamelize(name, '-') | ||
yargs.option(optionName, option) | ||
if (!setup.nycCommands.includes(command)) { | ||
yargs.hide(optionName) | ||
} | ||
}) | ||
}, | ||
cliWrapper (execute) { | ||
return argv => { | ||
execute(argv).catch(error => { | ||
console.error(error.message) | ||
process.exit(1) | ||
}) | ||
} | ||
} | ||
} |
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
Oops, something went wrong.