Skip to content
This repository was archived by the owner on Jul 19, 2021. It is now read-only.

Commit

Permalink
Quick fix: ThemeKit Update (#49)
Browse files Browse the repository at this point in the history
* dirty fix to remove themekit before reinstalling on setup command

* minor fixes
  • Loading branch information
Ryan Macdonald authored and Thomas Kelly committed Jul 31, 2017
1 parent 7501f2e commit 387e2e0
Showing 1 changed file with 28 additions and 7 deletions.
35 changes: 28 additions & 7 deletions packages/slate-cli/includes/themekit.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var Promise = require('bluebird');
var stat = Promise.promisify(require('fs').stat);
var unlink = Promise.promisify(require('fs').unlink);
var path = require('path');
var msg = require('./messages.js');
var BinWrapper = require('bin-wrapper');
Expand Down Expand Up @@ -36,17 +37,37 @@ module.exports = {
* @returns {Promise} - The ThemeKit installation
*/
install: function() {
var installer = this.get();
var exists = true;

return new Promise(function(resolve, reject) {
installer.run(['version'], function(error) {
if (error) {
reject(error);
return stat(this.path())
.catch(function(err) {
if (err.code === 'ENOENT') {
exists = false;
} else {
resolve();
throw new Error(err);
}
})
.then(function() {
if (exists) {
return unlink(this.path());
} else {
return Promise.resolve();
}
}.bind(this))
.then(function() {
return this.get();
}.bind(this))
.then(function(installer) {
return new Promise(function(resolve, reject) {
installer.run(['version'], function(err) {
if (err) {
reject(err);
} else {
resolve();
}
});
});
});
});
},

test: function() {
Expand Down

0 comments on commit 387e2e0

Please sign in to comment.