mirror of https://github.com/embarklabs/embark.git
42 lines
1.4 KiB
JavaScript
42 lines
1.4 KiB
JavaScript
// TODO: replace with something else more native to node
|
|
require('shelljs/global');
|
|
var path = require('path');
|
|
var wrench = require('wrench');
|
|
|
|
var run = function(cmd) {
|
|
var result = exec(cmd, {silent: true});
|
|
if (result.code !== 0) {
|
|
console.log(result.stderr);
|
|
exit();
|
|
}
|
|
};
|
|
|
|
var TemplateGenerator = function(templateName) {
|
|
this.templateName = templateName;
|
|
};
|
|
|
|
TemplateGenerator.prototype.generate = function(destinationFolder, name) {
|
|
var templatePath = path.join(__dirname, '/../', this.templateName);
|
|
console.log('Initializing Embark Template....'.green);
|
|
|
|
wrench.copyDirSyncRecursive(templatePath, destinationFolder + name);
|
|
cd(destinationFolder + name);
|
|
|
|
console.log('Installing packages.. this can take a few seconds'.green);
|
|
run('npm install');
|
|
console.log('Init complete'.green);
|
|
console.log('\nApp ready at '.green + destinationFolder + name);
|
|
|
|
if (name === 'embark_demo') {
|
|
console.log('-------------------'.yellow);
|
|
console.log('next steps:'.green);
|
|
console.log(('-> cd ' + destinationFolder + name).green);
|
|
console.log('-> embark blockchain or embark simulator'.green);
|
|
console.log('open another console in the same directory and run'.green);
|
|
console.log('-> embark run'.green);
|
|
console.log('For more info go to http://github.com/iurimatias/embark-framework'.green);
|
|
}
|
|
};
|
|
|
|
module.exports = TemplateGenerator;
|