Merge pull request #36 from ryantemple/master

updated to respect the bowerrc in the cwd passed in as command line argument
This commit is contained in:
Riyadh Al Nur
2015-11-24 13:06:05 +06:00
2 changed files with 21 additions and 1 deletions

View File

@@ -31,6 +31,8 @@ function rc(name, cwd, argv) {
json(find('.' + name + 'rc', cwd)),
env('npm_package_config_' + name + '_'),
env(name + '_'),
// If we have specified a cwd then the bowerrc from there takes precedence
!argvConfig.cwd ? {} : json(path.join(argvConfig.cwd, '.' + name + 'rc')),
argvConfig
]);
} else {
@@ -42,6 +44,8 @@ function rc(name, cwd, argv) {
json(path.join(paths.config, name + 'rc')),
env('npm_package_config_' + name + '_'),
env(name + '_'),
// If we have specified a cwd then the bowerrc from there takes precedence
!argvConfig.cwd ? {} : json(path.join(argvConfig.cwd, '.' + name + 'rc')),
argvConfig
]);
}

View File

@@ -20,13 +20,16 @@ describe('rc', function() {
'child3/bower.json': {
name: 'without-bowerrc'
},
'other_dir/.bowerrc': {
key: 'othervalue'
}
});
tempDirBowerrc.prepare({
'.bowerrc/foo': {
key: 'bar'
}
});
it('correctly reads .bowerrc files', function() {
@@ -57,6 +60,19 @@ describe('rc', function() {
expect(config.key2).to.eql(undefined);
});
it('loads the .bowerrc file from the cwd specified on the command line', function(){
var argv = {
'config': {
'cwd': tempDir.path + '/other_dir/'
}
};
var config = rc('bower', tempDir.path, argv);
expect(config.key).to.eql('othervalue');
});
it('throws an easy to understand error if .bowerrc is a dir', function() {
// Gotta wrap this to catch the error
var config = function () {