Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reorganizing library to support plugins
- Loading branch information
Damon Oehlman
committed
Jul 10, 2012
1 parent
7417536
commit 69c32e7
Showing
5 changed files
with
46 additions
and
36 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
var squirrel = require('squirrel'); | ||
|
||
module.exports = function(src, dest, callback) { | ||
var scaffolder = this; | ||
|
||
// create a dummy callback if we don't have one | ||
callback = callback || function() {}; | ||
|
||
squirrel(['ncp', 'mkdirp'], { allowInstall: 'prompt' }, function(err, ncp, mkdirp) { | ||
if (err) return callback(err); | ||
|
||
// get the source path for the package | ||
scaffolder.getPath(function(basePath) { | ||
src = path.resolve(basePath, src); | ||
|
||
debug('attempting to copy files from ' + src + ' ==> ' + dest); | ||
|
||
// if the path exists, copy the files | ||
_exists(src, function(exists) { | ||
if (exists) { | ||
mkdirp(dest, function(err) { | ||
if (err) { | ||
callback(err); | ||
} | ||
else { | ||
ncp(src, dest, callback); | ||
} | ||
}); | ||
} | ||
else { | ||
callback(new Error('no source files')); | ||
} | ||
}); | ||
}); | ||
}); | ||
}; |