Add support for colored output (disabled by default)

This commit is contained in:
Pavol Bielik 2015-01-26 21:31:12 +01:00
parent 55fac0c9e5
commit 9d013a10af
2 changed files with 24 additions and 2 deletions

View File

@ -7,7 +7,6 @@ var UglifyJS = require("../tools/node");
var sys = require("util");
var yargs = require("yargs");
var fs = require("fs");
var colors = require("colors");
var http = require('http');
var ARGS = yargs
@ -23,6 +22,7 @@ var ARGS = yargs
"FNAMES - function names to internal calls,\n" +
"FSCOPE - add variable scope constraints.")
.describe("package", "Build itself (UnuglifyJS) as a library")
.describe("colored", "Add colors to the output")
.describe("V", "Print version number and exit.")
//.demand(1)
.alias("V", "version")
@ -36,6 +36,7 @@ var ARGS = yargs
.boolean("nice_formatting")
.boolean("package")
.boolean("V")
.boolean("colors")
.string("features")
.string("nice2predict_server")
.wrap(80)
@ -49,6 +50,27 @@ var ARGS = yargs
normalize(ARGS);
if (ARGS.colors){
require("colors");
} else {
// in case we dont use colors simply return the string
var addProperty = function (color, func) {
String.prototype.__defineGetter__(color, func);
};
addProperty('red', function () {
return this;
});
addProperty('green', function () {
return this;
});
addProperty('yellow', function () {
return this;
});
}
if (ARGS.version || ARGS.V) {
var json = require("../package.json");
sys.puts(json.name + ' ' + json.version);

View File

@ -3,7 +3,7 @@
"description": "JavaScript tool that renames variables and parameters to names based on statistical model learnt from thousands of open source projects",
"homepage": "https://github.com/eth-srl/UnuglifyJS",
"main": "tools/node.js",
"version": "0.9.1",
"version": "0.9.2",
"engines": { "node" : ">=0.4.0" },
"maintainers": [{
"name": "Pavol Bielik",