Skip to content

Commit

Permalink
Add support for --root (#542)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincent Rouillé committed Jun 30, 2017
1 parent e9fad9f commit 28d8df7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/config-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Config.loadConfig = function (argv, cwd) {
config.extension = arrify(config.extension)
config.exclude = arrify(config.exclude)
config.include = arrify(config.include)
config.cwd = cwd
config.cwd = config.root || cwd

return config
}
Expand Down Expand Up @@ -132,6 +132,10 @@ Config.buildYargs = function (cwd) {
describe: 'a list of specific files that should be covered, glob patterns are supported',
global: false
})
.option('root', {
describe: 'the root path to look for files to instrument',
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 --root for cwd if it is set (highest priority and no look upwards for package.json) ', function () {
var nyc = new NYC(configUtil.loadConfig(['--root', __dirname], __dirname))
nyc.cwd.should.eql(__dirname)
})
})

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

0 comments on commit 28d8df7

Please sign in to comment.