Skip to content

Commit 84dc3c8

Browse files
committed
cwd fixes
1 parent 39c5d28 commit 84dc3c8

5 files changed

Lines changed: 16 additions & 12 deletions

File tree

lib/commands/install.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,7 @@ module.exports = function (dependencies) {
831831
}
832832

833833
function createInstallationTask(plugin) {
834-
return PackageMeta.getKeywords(plugin, { registry: Constants.getRegistry() }).then(doInstall).then(conclude);
834+
return PackageMeta.getKeywords(plugin, { registry: Constants.getRegistry(), cwd: Constants.cwd }).then(doInstall).then(conclude);
835835

836836
function doInstall(keywords) {
837837
var resolver = new PluginTypeResolver(),
@@ -841,8 +841,9 @@ module.exports = function (dependencies) {
841841
plugin._belongsTo = pluginType.belongsTo;
842842

843843
return install(plugin, {
844-
directory: path.join(Constants.cwd, 'src', pluginType.belongsTo),
845-
registry: Constants.getRegistry()
844+
directory: path.join('src', pluginType.belongsTo),
845+
registry: Constants.getRegistry(),
846+
cwd: Constants.cwd
846847
});
847848
}
848849

lib/commands/install/InstallTarget.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ var InstallTarget = extend(Plugin, {
8787
try {
8888
var versionString = this._versions ? '#'+this._versions[this._versionIndex] : '';
8989
this._bowerCmdCount++;
90-
bower.commands.info(this.packageName+versionString, null, {registry:Constants.getRegistry()}).on('end', _.bind(onSuccess, this)).on('error', _.bind(onFail, this));
90+
bower.commands.info(this.packageName+versionString, null, {registry:Constants.getRegistry(), cwd: Constants.cwd}).on('end', _.bind(onSuccess, this)).on('error', _.bind(onFail, this));
9191
} catch(err) {
9292
onFail.call(this, err);
9393
}

lib/commands/uninstall.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ module.exports = {
3131
pluginType = resolver.resolve(keywords);
3232

3333
return uninstallPackage(plugin, {
34-
directory: path.join(Constants.cwd, 'src', pluginType.belongsTo)
34+
directory: path.join('src', pluginType.belongsTo),
35+
cwd:Constants.cwd
3536
});
3637
})
3738
.then(function () {
@@ -93,7 +94,8 @@ module.exports = {
9394

9495
renderer.log(chalk.cyan(plugin.packageName), 'found.', 'Uninstalling', pluginType.typename, '...');
9596
return uninstallPackage(plugin, {
96-
directory: path.join(Constants.cwd, 'src', pluginType.belongsTo)
97+
directory: path.join('src', pluginType.belongsTo),
98+
cwd:Constants.cwd
9799
});
98100
})
99101
.then(function () {

lib/commands/update.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ module.exports = function() {
376376
//console.log('Querying registry for', plugin.packageName, '(' + plugin.version + ')');
377377
var versionString = plugin._versions ? '#'+plugin._versions[plugin._versionIndex] : '';
378378
plugin._bowerCmdCount++;
379-
bower.commands.info(plugin.packageName+versionString, null, {registry:Constants.getRegistry()}).on('end', onSuccess).on('error', onFail);
379+
bower.commands.info(plugin.packageName+versionString, null, {registry:Constants.getRegistry(), cwd:Constants.cwd}).on('end', onSuccess).on('error', onFail);
380380
} catch(err) {
381381
onFail();
382382
}
@@ -794,8 +794,8 @@ module.exports = function() {
794794
}
795795

796796
function clean() {
797-
if (fs.existsSync('bower.json')) {
798-
fs.unlinkSync('bower.json');
797+
if (fs.existsSync(path.join(Constants.cwd, 'bower.json'))) {
798+
fs.unlinkSync(path.join(Constants.cwd, 'bower.json'));
799799
}
800800
return Q.resolve();
801801
}
@@ -812,11 +812,12 @@ module.exports = function() {
812812
manifest = _.extend({}, bowerJson, {dependencies:deps});
813813

814814
//console.log('manifest\n', JSON.stringify(manifest, null, 4));
815-
JsonWriter.writeJSONSync('bower.json', manifest);
815+
JsonWriter.writeJSONSync(path.join(Constants.cwd, 'bower.json'), manifest);
816816
//console.log(JSON.stringify(JsonLoader.readJSONSync('bower.json'), null, 4));
817817
return update(plugin, null, {
818-
directory: path.join(Constants.cwd, 'src', plugin._belongsTo),
818+
directory: path.join('src', plugin._belongsTo),
819819
registry: Constants.getRegistry(),
820+
cwd:Constants.cwd,
820821
force:true
821822
})
822823
.then(function (result) {

lib/promise/install.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module.exports = function install (plugin, config) {
88
var deferred = Q.defer();
99

1010
// (reliably) remove the plugin first
11-
rimraf(path.join(config.directory, plugin.packageName), {disableGlob:true}, doInstall);
11+
rimraf(path.join(config.cwd || '.', config.directory, plugin.packageName), {disableGlob:true}, doInstall);
1212

1313
function doInstall(err) {
1414
if (err) {

0 commit comments

Comments
 (0)