Skip to content

Commit

Permalink
fix: default config values for yml files (#171)
Browse files Browse the repository at this point in the history
* updated various dev dependencies
  jest-cli seems to have improved the stability of the tests
  • Loading branch information
Nick Woodward authored and Kent C. Dodds committed Feb 28, 2018
1 parent b5769c9 commit f9a7b0b
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 12 deletions.
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
"all-contributors-cli": "^4.3.0",
"babel-cli": "^6.24.1",
"babel-eslint": "^7.2.3",
"babel-jest": "^20.0.3",
"babel-plugin-module-resolver": "^2.7.1",
"babel-jest": "^22.0.0",
"babel-plugin-module-resolver": "^3.0.0",
"babel-preset-env": "^1.6.0",
"babel-preset-stage-2": "^6.24.1",
"babel-register": "^6.24.1",
Expand All @@ -48,8 +48,8 @@
"eslint-plugin-import": "2.7.0",
"eslint-plugin-jest": "20.0.3",
"husky": "0.14.3",
"jest-cli": "^20.0.4",
"lint-staged": "^4.0.1",
"jest-cli": "^22.0.0",
"lint-staged": "^7.0.0",
"nps": "^5.4.0",
"nps-utils": "^1.2.0",
"opt-cli": "^1.5.1",
Expand All @@ -62,7 +62,8 @@
"kentcdodds/prettier"
],
"rules": {
"max-len": "off"
"max-len": "off",
"max-lines": "off"
}
},
"lint-staged": {
Expand Down
2 changes: 0 additions & 2 deletions src/bin-utils/__tests__/fixtures/fake-config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
scripts:
skywalker: echo "That's impossible!!"

options: {}
6 changes: 4 additions & 2 deletions src/bin-utils/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,16 @@ test('loadConfig: logs a warning when the YAML file cannot be located', () => {
)
})

test('loadConfig: can load config from YML file', () => {
test('loadConfig: can load config from a YML file', () => {
const relativePath = './src/bin-utils/__tests__/fixtures/fake-config.yml'
const val = loadConfig(relativePath)
expect(val).toEqual({
scripts: {
skywalker: `echo "That's impossible!!"`,
},
options: {},
options: {
'help-style': 'all',
},
})
})

Expand Down
6 changes: 4 additions & 2 deletions src/bin-utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,13 @@ const loadJSConfig = getAttemptModuleRequireFn(function onFail(
*/
// eslint-disable-next-line complexity
function loadConfig(configPath, input) {
let config
if (configPath.endsWith('.yml')) {
return loadYAMLConfig(configPath)
config = loadYAMLConfig(configPath)
} else {
config = loadJSConfig(configPath)
}

let config = loadJSConfig(configPath)
if (isUndefined(config)) {
// let the caller deal with this
return config
Expand Down
1 change: 1 addition & 0 deletions src/bin-utils/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ function parse(rawArgv) {

// util functions

// eslint-disable-next-line complexity
function showHelp(specifiedScripts) {
if (parsedArgv.help) {
// if --help was specified, then yargs will show the default help
Expand Down
2 changes: 1 addition & 1 deletion test/jest.src.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
rootDir: '../src',
collectCoverage: true,
testEnvironment: 'node',
collectCoverageFrom: ['src/**/*.js'],
testPathIgnorePatterns: ['/node_modules/', '/fixtures/', '/helpers/'],
coveragePathIgnorePatterns: [
'/node_modules/',
Expand Down

0 comments on commit f9a7b0b

Please sign in to comment.