Skip to content

Commit e8b0150

Browse files
author
Aaron O'Mullan
committed
Fix addon unlink bug
1 parent c67740a commit e8b0150

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

core/cb.addons/main.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,22 @@ function setup(options, imports, register, app) {
7979

8080
return first.then(runAddonsOperation(function(addon) {
8181
logger.log("Adding default addon", addon.infos.name);
82-
return Q.nfcall(fs.unlink, path.resolve(configAddonsPath, addon.infos.name)).then(function() {
82+
83+
// Path to addon
84+
var addonPath = path.resolve(configAddonsPath, addon.infos.name);
85+
86+
var d = Q.defer();
87+
fs.exists(addonPath, d.resolve);
88+
89+
return d.promise
90+
.then(function(exists) {
91+
if(!exists) return false;
92+
93+
// Unlink only if exists
94+
return Q.nfcall(fs.unlink, addonPath);
95+
})
96+
.then(function() {
97+
// Relink it
8398
return addon.symlink(configAddonsPath);
8499
});
85100
}));
@@ -90,7 +105,7 @@ function setup(options, imports, register, app) {
90105
var addon, tempDir;
91106

92107
options = _.defaults({}, options || {}, {
93-
108+
94109
});
95110

96111
logger.log("Install add-on", git);

0 commit comments

Comments
 (0)