Add support for colored output (disabled by default)
This commit is contained in:
parent
55fac0c9e5
commit
9d013a10af
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user