UNPKG

hck2-dev

Version:

Development Tools For HCK2

71 lines (51 loc) 2.26 kB
var child = require('child_process'); function init(option, cb) { // if (option.build) { // return child.exec('composer exec jigsaw build', function (err, stdout, stderr) { // console.log('Jigsaw Build Complete'.blue); // cb(); // }); // } install(function () { console.log('Successfully Installed Jigsaw!'.green); child.exec('composer exec jigsaw init', function (err, stdout, stderr) { if (err) return console.log('Jigsaw May Already Be Initialized'.red); if (stderr) return console.log('Jigsaw May Already Be Initialized'.red); console.log('Jigsaw Initialized!'.yellow); setTimeout(copyFiles, 3000); }); }); } function install(cb) { child.exec('composer -V', function (err, data, stderr) { console.log('\x1Bc'); if (stderr) return console.log('Composer Not Found. Please Install Composer Globally'.bgRed.red); console.log('Composer Found! Installing Jigsaw. Please Wait...'.green); child.exec('composer require tightenco/jigsaw', function (err, stdout, stderr) { // if (stderr) return console.log(stderr); if (err) return console.log(err); cb(); }); }); } function copyFiles() { fs.remove('./source', function (err) { if (err) return console.log(err); fs.copy('./node_modules/hck2-dev/jigsaw/source', './source', err => { if (err) return console.error(err); console.log('Copying Source Folder'.yellow); console.log('Copying Boilerplate Files'.yellow); fs.copySync('./node_modules/hck2-dev/Boilerplate/src/js', './source/_assets/js') fs.copySync('./node_modules/hck2-dev/Boilerplate/src/sass', './source/_assets/sass') }); fs.copy('./node_modules/hck2-dev/jigsaw/config.json', './config.json', err => { if (err) return console.error(err); console.log('Updated config.json'.yellow); }); fs.removeSync('./webpack.mix.js'); fs.removeSync('./Boilerplate'); }); } module.exports = { init };