Skip to content

Commit

Permalink
chore: add support for --cwd (#542) (#620)
Browse files Browse the repository at this point in the history
  • Loading branch information
Speedy37 authored and bcoe committed Sep 5, 2017
1 parent 658dba4 commit 0fc6d8f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/config-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ Config.loadConfig = function (argv, cwd) {
config.extension = arrify(config.extension)
config.exclude = arrify(config.exclude)
config.include = arrify(config.include)
config.cwd = cwd

return config
}
Expand Down Expand Up @@ -136,6 +135,10 @@ Config.buildYargs = function (cwd) {
describe: 'a list of specific files that should be covered, glob patterns are supported',
global: false
})
.option('cwd', {
describe: 'working directory to lookup for files',
global: false
})
.option('require', {
alias: 'i',
default: [],
Expand Down
5 changes: 5 additions & 0 deletions test/src/nyc-tap.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ describe('nyc', function () {
var nyc = new NYC(configUtil.loadConfig([], __dirname))
nyc.cwd.should.eql(path.join(__dirname, '../..'))
})

it('uses --cwd for cwd if it is set (highest priority and no look upwards for package.json) ', function () {
var nyc = new NYC(configUtil.loadConfig(['--cwd', __dirname], __dirname))
nyc.cwd.should.eql(__dirname)
})
})

describe('config', function () {
Expand Down

0 comments on commit 0fc6d8f

Please sign in to comment.