#!/usr/bin/env node

var exec = require('child_process').exec;
var path = require('path');
var gulpSrc = path.resolve(__dirname, './node_modules/.bin/gulp');
var gulpFile = path.resolve(__dirname, './gulpfile.js');
var cmdStr = gulpSrc + ' --gulpfile ' + gulpFile + ' --arg ' + process.cwd();
console.log("执行命令", cmdStr, '===========');
console.log(new Date(), '开始编译');
exec(cmdStr, (err, stdout, stderr) => {
    if (err) {
        console.error(err);
        console.warn(new Date(), '编译失败');
        process.exit(1);
    } else {
        console.log(stdout);
        console.warn(new Date(), '编译完成');
    }
});
