UNPKG

after-brunch-gbk

Version:

A micro-plugin to run commands line scripts after Brunch's compile.

55 lines (45 loc) 1.39 kB
// Generated by CoffeeScript 1.6.3 var AfterBrunch, exec, sysPath; sysPath = require('path'); exec = require('child_process').exec; var spawn = require('child_process').spawn; var iconv = require('iconv-lite'); module.exports = AfterBrunch = (function() { AfterBrunch.prototype.brunchPlugin = true; function AfterBrunch(config) { var _ref; this.config = config; this.commands = (_ref = this.config.plugins.afterBrunch) != null ? _ref : []; } AfterBrunch.prototype.onCompile = function(generatedFiles) { console.log("exec AfterBrunch:"); var command, _i, _len, _ref; _ref = this.commands; for (_i = 0, _len = _ref.length; _i < _len; _i++) { command = _ref[_i]; var child = spawn(command); child.stdout.on('data', function (data) { console.log(iconv.decode(data,"GBK")); }); child.stderr.on('data', function (data) { console.log(iconv.decode(data,"GBK")); }); child.on('close', function (code) { //console.log('child process exited with code ' + code); }); /* exec(command, function(error, stdout, stderr) { if (stdout) { console.log(stdout); } if (error) { console.log(error.message); } if (stderr) { return console.log(stderr); } }); */ } }; return AfterBrunch; })();