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

feat: Add support for yaml configuration file #1054

Merged
merged 10 commits into from Apr 16, 2019

add support for 'yaml', code coverage fix

  • Loading branch information...
c-bandy committed Apr 5, 2019
commit f8dec6d41694a9817a58fcbc8e240bd61fd7bd14
@@ -40,13 +40,23 @@ Config.loadConfig = function (argv, cwd) {
if (rcPathLower.endsWith('.js')) {
config = require(rcPath)
} else if (/.+\.y(a?)ml$/.test(rcPathLower)) {
if (moduleExists('js-yaml')) {
console.error('you need to install js-yaml to use a yaml configuration file')
process.exit(1)
const installedYamlParser = ['js-yaml', 'yaml'].find((name) => moduleExists(name))
This conversation was marked as resolved by c-bandy

This comment has been minimized.

Copy link
@bcoe

bcoe Apr 9, 2019

Member

I'd honestly rather converge on one yaml parser, seems like overkill to support multiple flavors.

what's the reason to not just support js-yaml, it seems to be the more popular.

This comment has been minimized.

Copy link
@JaKXz

JaKXz Apr 10, 2019

Member

@isaacs mentioned supporting both in a previous comment

switch (installedYamlParser) {
case 'js-yaml':
config = require('js-yaml').load(
fs.readFileSync(rcPath, 'utf8')
)
break
case 'yaml':
This conversation was marked as resolved by c-bandy

This comment has been minimized.

Copy link
@coreyfarrell

coreyfarrell Apr 5, 2019

Member

Need to tell istanbul to ignore the yaml case as well since testing will always find js-yaml.

config = require('yaml').parse(
fs.readFileSync(rcPath, 'utf8')
)
break
/* istanbul ignore next */
default:
console.error('you need to install a yaml parser to use a yaml configuration file')
process.exit(1)
}
config = require('js-yaml').load(
fs.readFileSync(rcPath, 'utf8')
)
} else {
config = JSON.parse(
fs.readFileSync(rcPath, 'utf-8')
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.