Skip to content

Commit

Permalink
feat: extend *.rc files in addition to json (#1080)
Browse files Browse the repository at this point in the history
  • Loading branch information
genepaul authored and bcoe committed Mar 4, 2018
1 parent a04678c commit 11691a6
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/apply-extends.js
Expand Up @@ -21,7 +21,7 @@ function applyExtends (config, cwd) {

if (config.hasOwnProperty('extends')) {
if (typeof config.extends !== 'string') return defaultConfig
const isPath = /\.json$/.test(config.extends)
const isPath = /\.json|\..*rc$/.test(config.extends)
let pathToDefault = null
if (!isPath) {
try {
Expand Down
4 changes: 4 additions & 0 deletions test/fixtures/extends/.myotherrc
@@ -0,0 +1,4 @@
{
"extends": "./config_1.json",
"c": 201
}
4 changes: 4 additions & 0 deletions test/fixtures/extends/.myrc
@@ -0,0 +1,4 @@
{
"extends": "./.myotherrc",
"a": 5
}
14 changes: 14 additions & 0 deletions test/yargs.js
Expand Up @@ -1284,6 +1284,20 @@ describe('yargs dsl tests', () => {
argv.a.should.equal(2)
argv.extends.should.equal('batman')
})

it('allows files with .*rc extension to be extended', () => {
const argv = yargs()
.config({
extends: './test/fixtures/extends/.myrc',
a: 3
})
.argv

argv.a.should.equal(3)
argv.b.should.equal(22)
argv.c.should.equal(201)
argv.z.should.equal(15)
})
})
})

Expand Down

0 comments on commit 11691a6

Please sign in to comment.