Skip to content

Commit

Permalink
Add detection for .yaml and .yml
Browse files Browse the repository at this point in the history
PR-URL: #717
Credit: @jsumners
Close: #717
Reviewed-by: @isaacs

EDIT(@isaacs): clean up test somewhat to use t.testdir() instead of
manually creating and removing files.
  • Loading branch information
jsumners authored and isaacs committed Mar 26, 2021
1 parent 75bae93 commit 564e96f
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
11 changes: 10 additions & 1 deletion bin/run.js
Expand Up @@ -826,7 +826,16 @@ const parseRcFile = path => {
let contents
try {
contents = fs.readFileSync(path, 'utf8')
} catch (er) {
} catch (_) {
try {
contents = fs.readFileSync(path + '.yaml', 'utf8')
} catch (_) {
try {
contents = fs.readFileSync(path + '.yml', 'utf8')
} catch (_) {}
}
}
if (!contents) {
// if no dotfile exists, just return an empty object
return {}
}
Expand Down
27 changes: 27 additions & 0 deletions test/run/rcfile-extensions.js
@@ -0,0 +1,27 @@
const {
run,
dir,
t,
} = require('./')

const fs = require('fs')
t.test('finds rc file with .yaml and .yml', t => {
const files = [
'.taprc',
'.taprc.yml',
'.taprc.yaml',
]

t.plan(files.length)
for (const file of files) {
t.test(file, t => {
const cwd = t.testdir({
[file]: 'check-coverage: false',
})
run(['--dump-config'], { cwd }, (er, o, e) => {
t.match(o, /check-coverage: false/)
t.end()
})
})
}
})

0 comments on commit 564e96f

Please sign in to comment.