diff --git a/lib/core/Project.js b/lib/core/Project.js index 2c4f34101..62f649b74 100644 --- a/lib/core/Project.js +++ b/lib/core/Project.js @@ -213,6 +213,20 @@ Project.prototype.update = function (names, options) { }); }; +function resolveUrlNames(names, flattened) +{ + for (var i = 0; i < names.length; i++) + if (! flattened[names[i]]) + { + var url = names[i].trim().replace(/\/$/, ''); + var packName; + for (packName in flattened) + if (! ( !flattened[packName].source)) + if (url == flattened[packName].source.trim().replace(/\/$/, '')) + names[i] = packName; + } +} + Project.prototype.uninstall = function (names, options) { var that = this; var packages = {}; @@ -230,6 +244,7 @@ Project.prototype.uninstall = function (names, options) { // Fill in the packages to be uninstalled .spread(function (json, tree, flattened) { var promise = Q.resolve(); + resolveUrlNames(names, flattened); names.forEach(function (name) { var decEndpoint = flattened[name]; diff --git a/test/commands/uninstall.js b/test/commands/uninstall.js index 5e02b7e0b..db3ecbb51 100644 --- a/test/commands/uninstall.js +++ b/test/commands/uninstall.js @@ -99,4 +99,21 @@ describe('bower uninstall', function () { }); }); + it('removes a project with url from absolute path', function () { + var targetPath = path.resolve(tempDir.path, 'other_directory/underscore'); + mkdirp.sync(targetPath); + fs.writeFileSync(path.join(targetPath, '.bower.json'), '{ "name": "underscore", "_source": "git://github.com/user/repo.git" }'); + + return helpers.run(uninstall, [['git://github.com/user/repo.git'], undefined, { + cwd: tempDir.path, + directory: path.resolve(tempDir.path, 'other_directory'), + interactive: true + }]) + .then(function () { + expect(function () { + fs.statSync(targetPath); + }).to.throwException(/no such file or directory/); + }); + }); + });