check server version

This commit is contained in:
Pavol Bielik 2015-01-27 16:27:35 +01:00
parent 9d013a10af
commit 027027634d
2 changed files with 23 additions and 13 deletions

View File

@ -8,6 +8,7 @@ var sys = require("util");
var yargs = require("yargs");
var fs = require("fs");
var http = require('http');
var json = require("../package.json");
var ARGS = yargs
.usage("$0 input1.js \n")
@ -72,7 +73,7 @@ if (ARGS.colors){
}
if (ARGS.version || ARGS.V) {
var json = require("../package.json");
//var json = require("../package.json");
sys.puts(json.name + ' ' + json.version);
process.exit(0);
}
@ -213,7 +214,12 @@ function processFile(file) {
"infer",
JSON.parse(output),
function(data) {
var result = JSON.parse(data).result;
var data_json = JSON.parse(data);
if (data_json.hasOwnProperty('error')){
console.log("ERROR: ".red + data_json.error.message);
}
else if (data_json.hasOwnProperty('result')) {
var result = data_json.result;
var inferred_names = {};
for (var i = 0; i < result.length; i++) {
if (result[i].hasOwnProperty("inf")) {
@ -226,6 +232,9 @@ function processFile(file) {
} catch (ex) {
sys.error("ERROR: ".red + "failed rename '" + file + "': " + ex);
}
} else {
sys.error("ERROR: ".red + "undefined response. Try to update unuglify-js to the latest version by 'npm update -g unuglify-js'");
}
},
function(err) {
@ -261,6 +270,7 @@ function callServer(server, port, methodName, params, success_cb, error_cb) {
method : methodName,
id : (++json_rpc_id)
};
params.version = json.version;
req.params = params;
var post_data = JSON.stringify(req);

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.2",
"version": "0.9.3",
"engines": { "node" : ">=0.4.0" },
"maintainers": [{
"name": "Pavol Bielik",