-
-
Notifications
You must be signed in to change notification settings - Fork 360
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 (#1194)
BREAKING CHANGE: The `flow` and `jsx` parser plugins are no longer enabled by default.
- Loading branch information
1 parent
96b60b8
commit fd40d49
Showing
12 changed files
with
97 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,61 @@ | ||
'use strict' | ||
|
||
const decamelize = require('decamelize') | ||
const schema = require('@istanbuljs/schema') | ||
|
||
/* These options still need to be connected to the instrumenter | ||
* Disabling them for now also avoids the issue with OSX cutting | ||
* off the error help screen at 8192 characters. | ||
*/ | ||
const blockOptions = [ | ||
'coverageVariable', | ||
'coverageGlobalScope', | ||
'coverageGlobalScopeFunc' | ||
] | ||
|
||
module.exports = { | ||
setupOptions (yargs, command, cwd) { | ||
Object.entries(schema.nyc.properties).forEach(([name, setup]) => { | ||
if (blockOptions.includes(name)) { | ||
return | ||
} | ||
|
||
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.