If cwd provided explicitly, force using it, fixes #1866

This commit is contained in:
Adam Stankiewicz
2015-08-23 16:24:36 +02:00
parent 8531534241
commit dd67cc7de0
4 changed files with 14 additions and 5 deletions

View File

@@ -13,6 +13,12 @@ var createError = require('../util/createError');
function init(logger, config) {
var project;
config = config || {};
if (!config.cwd) {
config.cwd = process.cwd();
}
config = defaultConfig(config);
// This command requires interactive to be enabled

View File

@@ -10,9 +10,9 @@ var cachedConfigs = {};
function defaultConfig(config) {
config = config || {};
var cwd = path.dirname(findup('bower.json', {
cwd: config.cwd || process.cwd()
})) || config.cwd || process.cwd();
var cwd = config.cwd || path.dirname(findup('bower.json', {
cwd: process.cwd()
})) || process.cwd();
config.cwd = cwd;

View File

@@ -93,4 +93,4 @@ module.exports = {
postinstall: mout.function.partial(hook, 'postinstall', true),
//only exposed for test
_orderByDependencies: orderByDependencies
};
};

View File

@@ -1,3 +1,4 @@
var path = require('path');
var expect = require('expect.js');
var helpers = require('../helpers');
@@ -147,7 +148,9 @@ describe('bower install', function () {
}
});
return helpers.run(install, [undefined, undefined, { cwd: tempDir.path + '/foo/bar' }]).then(function() {
process.chdir(path.join(tempDir.path, '/foo/bar'));
return helpers.run(install).then(function() {
expect(tempDir.read('assets/package/foo')).to.be('bar');
});
});