From 4146442cd979f834591d0a1a8927635d0fe52a3c Mon Sep 17 00:00:00 2001 From: Sven Lito Date: Tue, 22 Jul 2014 12:49:24 +0200 Subject: [PATCH] refactor(mkdir utils): split functions --- lib/cli/util/notifier.js | 2 +- lib/hoodie/new.js | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/lib/cli/util/notifier.js b/lib/cli/util/notifier.js index 52d9434..fe877ca 100644 --- a/lib/cli/util/notifier.js +++ b/lib/cli/util/notifier.js @@ -6,7 +6,6 @@ module.exports = function() { var notifier = updateNotifier({ packageName: pkg.name, packageVersion: pkg.version, - packagePath: '../../../package', updateCheckInterval: 1000 * 60 * 60 * 1 // 1 hr }); @@ -15,3 +14,4 @@ module.exports = function() { } }; + diff --git a/lib/hoodie/new.js b/lib/hoodie/new.js index 07d43f5..d10b57f 100644 --- a/lib/hoodie/new.js +++ b/lib/hoodie/new.js @@ -106,22 +106,30 @@ CreateCommand.prototype.fetch = function (options, ctx, callback) { }; -// -// Copy template directory to target location. -// -Command.prototype.copyToCwd = function (options, ctx, callback) { +Command.prototype.mkdir = function (options, ctx, callback) { var self = ctx; - var srcDir = path.resolve(path.join('node_modules', options.template.template)); var targetDir = dirUtils.appDir(options); try { shell.mkdir('-p', path.dirname(targetDir)); + callback(); } catch(e) { self.hoodie.emit('err', 'directory already exists'); return callback(new Error()); } +}; + +// +// Copy template directory to target location. +// +Command.prototype.copyToCwd = function (options, ctx, callback) { + + var self = ctx; + var srcDir = path.resolve(path.join('node_modules', options.template.template)); + var targetDir = dirUtils.appDir(options); + try { self.hoodie.emit('info', 'Preparing: ' + options.name + ' ...'); shell.cp('-R', srcDir + '/.', targetDir); @@ -210,6 +218,7 @@ CreateCommand.prototype.execute = function (options) { async.applyEachSeries([ self.fetch, + self.mkdir, self.copyToCwd, self.cleanup, self.rename