[gulp] move tasks to gulp-haxetool package

This commit is contained in:
2018-04-03 15:12:53 +03:00
parent 92a2628e90
commit 836eebaf11
15 changed files with 34 additions and 967 deletions

64
build/debug.js Executable file
View File

@@ -0,0 +1,64 @@
const net = require('net');
const through = require('through2');
const colors = require('ansi-colors');
const log = require('fancy-log');
const _colors = {
'[DEBUG]': colors.white,
'[INFO]': colors.cyan,
'[ERROR]': colors.red,
'[WARNING]': colors.yellow,
};
const getColor = (line) => {
for (const [tag, color] of Object.entries(_colors)) {
if (line.indexOf(tag) > -1) {
return color;
}
}
return null;// colors.reset;
};
const _log = (line, color) => {
if (color === undefined) {
color = getColor(line) || colors.white;
}
if (line[0] === '\t') {
console.log(color(line))
} else {
const result = line.split(' ');
console.log(colors.gray(result.slice(0, 4).join(' ')) + ' ' + color(result.slice(4).join(' ')));
}
};
module.exports = () => {
return through.obj(function (file, enc, callback) {
const debug = file.debug;
if (!file.debug) {
this.emit('end');
callback();
return;
}
let color = colors.white;
const server = net.createServer((socket) => {
socket.on("data", (data) => {
const lines = data.toString().split('\n');
for (let line of lines) if (line.length > 2) {
const newColor = getColor(line);
if (newColor != null) color = newColor;
_log(line, color);
}
});
socket.on("close", () => {
socket.destroy();
server.close();
this.emit('end');
callback();
});
});
log(colors.green('[debug]'), colors.cyan('listen on'), colors.magenta(`${debug.host}:${debug.port}`));
server.listen(debug.port, debug.host);
})
};
module.exports.log = _log;