Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make bower commands work from subdirectories #1866

Merged
merged 1 commit into from
Aug 23, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,21 @@ var tty = require('tty');
var object = require('mout').object;
var bowerConfig = require('bower-config');
var Configstore = require('configstore');
var findup = require('findup-sync');
var path = require('path');

var cachedConfigs = {};

function defaultConfig(config) {
config = config || {};

var cachedConfig = readCachedConfig(config.cwd || process.cwd());
var cwd = path.dirname(findup('bower.json', {
cwd: config.cwd || process.cwd()
})) || config.cwd || process.cwd();

config.cwd = cwd;

var cachedConfig = readCachedConfig(cwd);

return object.merge(cachedConfig, config);
}
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"configstore": "^0.3.2",
"decompress-zip": "^0.1.0",
"deep-sort-object": "~0.1.1",
"findup-sync": "^0.2.1",
"fstream": "^1.0.3",
"fstream-ignore": "^1.0.2",
"github": "^0.2.3",
Expand Down
19 changes: 19 additions & 0 deletions test/commands/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,25 @@ describe('bower install', function () {
});
});

it.only('works if bower is run in child directory', function () {
package.prepare({ foo: 'bar' });

tempDir.prepare({
'.bowerrc': { directory: 'assets' },
'foo/bar/baz.txt': 'Hello world',
'bower.json': {
name: 'test',
dependencies: {
package: package.path
}
}
});

return helpers.run(install, [undefined, undefined, { cwd: tempDir.path + '/foo/bar' }]).then(function() {
expect(tempDir.read('assets/package/foo')).to.be('bar');
});
});

it('runs preinstall hook', function () {
package.prepare();

Expand Down