-
Notifications
You must be signed in to change notification settings - Fork 15
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
feat(config): allow defining files via flag #201
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,7 @@ program | |
.argument('[files...]', 'a glob of files to to test the EcmaScript version against') | ||
.option('--module', 'use ES modules') | ||
.option('--allow-hash-bang', 'if the code starts with #! treat it as a comment') | ||
.option('--files <files>', 'a glob of files to to test the EcmaScript version against (alias for [files...])') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't include the |
||
.option('--not <files>', 'folder or file names to skip') | ||
.option('--no-color', 'disable use of colors in output') | ||
.option('-v, --verbose', 'verbose mode: will also output debug messages') | ||
|
@@ -53,6 +54,11 @@ program | |
|
||
const configFilePath = path.resolve(process.cwd(), '.escheckrc') | ||
|
||
if (filesArg && filesArg.length && options.files) { | ||
logger.error('Cannot pass in both [files...] argument and --files flag at the same time!') | ||
process.exit(1) | ||
} | ||
Comment on lines
+57
to
+60
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd originally thought to have the argument override the flag, but then I could see someone misunderstanding that maybe they got concatenated and it seemed like erroring is the only safe option. Totally open to feedback on this idea or the error message text. |
||
|
||
/** | ||
* @note | ||
* Check for a configuration file. | ||
|
@@ -61,7 +67,8 @@ program | |
*/ | ||
const config = fs.existsSync(configFilePath) ? JSON.parse(fs.readFileSync(configFilePath)) : {} | ||
const expectedEcmaVersion = ecmaVersionArg ? ecmaVersionArg : config.ecmaVersion | ||
const files = filesArg && filesArg.length ? filesArg : [].concat(config.files) | ||
const files = | ||
filesArg && filesArg.length ? filesArg : options.files ? options.files.split(',') : [].concat(config.files) | ||
const esmodule = options.module ? options.module : config.module | ||
const allowHashBang = options.allowHashBang ? options.allowHashBang : config.allowHashBang | ||
const pathsToIgnore = options.not ? options.not.split(',') : [].concat(config.not || []) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added surrounding newlines to match pattern elsewhere