Skip to content

Commit

Permalink
refactor(mkdir utils): split functions
Browse files Browse the repository at this point in the history
  • Loading branch information
svnlto committed Jul 22, 2014
1 parent e5cdc9a commit 4146442
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/cli/util/notifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
});

Expand All @@ -15,3 +14,4 @@ module.exports = function() {
}

};

19 changes: 14 additions & 5 deletions lib/hoodie/new.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -210,6 +218,7 @@ CreateCommand.prototype.execute = function (options) {

async.applyEachSeries([
self.fetch,
self.mkdir,
self.copyToCwd,
self.cleanup,
self.rename
Expand Down

0 comments on commit 4146442

Please sign in to comment.