fis-command-server
Advanced tools
Comparing version 0.6.5 to 0.6.7
@@ -0,0 +0,0 @@ Copyright (C) 2013 baidu.com |
{ | ||
"name" : "fis-command-server", | ||
"description" : "fis server command.", | ||
"version" : "0.6.5", | ||
"version" : "0.6.7", | ||
"author" : "FIS Team <fis@baidu.com>", | ||
@@ -6,0 +6,0 @@ "homepage" : "http://fis.baidu.com/", |
@@ -15,30 +15,13 @@ /* | ||
var spawn = child_process.spawn; | ||
var tmp_dir = (function(){ | ||
var list = ['LOCALAPPDATA', 'APPDATA', 'HOME'], tmp; | ||
for(var i = 0, len = list.length; i < len; i++){ | ||
if(tmp = process.env[list[i]]){ | ||
break; | ||
} | ||
} | ||
if(tmp){ | ||
tmp += '/.fis-tmp/server'; | ||
if(!fis.util.exists(tmp)){ | ||
fis.util.mkdir(tmp); | ||
} | ||
} else { | ||
tmp = __dirname; | ||
} | ||
if(fis.util.isDir(tmp)){ | ||
return fis.util.realpath(tmp); | ||
} else { | ||
fis.log.error('invalid temp directory [' + tmp + ']'); | ||
} | ||
})(); | ||
function getConf(){ | ||
function getRCFile(){ | ||
return fis.project.getTempPath('server/conf.json'); | ||
} | ||
function getPidFile(){ | ||
return fis.project.getTempPath('server/pid'); | ||
} | ||
function stop(callback){ | ||
var tmp = tmp_dir + '/pid'; | ||
var tmp = getPidFile(); | ||
if(fis.util.exists(tmp)){ | ||
@@ -173,3 +156,3 @@ var pid = fis.util.fs.readFileSync(tmp, 'utf8').trim(); | ||
server.unref(); | ||
fis.util.write(tmp_dir + '/pid', server.pid); | ||
fis.util.write(getPidFile(), server.pid); | ||
setTimeout(function(){ | ||
@@ -183,3 +166,3 @@ process.stdout.write(' fail\n'); | ||
function start(opt){ | ||
var tmp = getConf(); | ||
var tmp = getRCFile(); | ||
if(opt){ | ||
@@ -195,14 +178,2 @@ fis.util.write(tmp, JSON.stringify(opt)); | ||
if(opt.root){ | ||
if(fis.util.exists(opt.root)){ | ||
if(!fis.util.isDir(opt.root)){ | ||
fis.log.error('document root [' + opt.root + '] is not a directory'); | ||
} | ||
} else { | ||
fis.util.mkdir(opt.root); | ||
} | ||
} else { | ||
fis.log.error('invalid document root'); | ||
} | ||
//check java | ||
@@ -308,5 +279,18 @@ process.stdout.write('checking java support : '); | ||
var serverRoot = (function(){ | ||
var key = 'FIS_SERVER_DOCUMENT_ROOT'; | ||
if(process.env && process.env[key]){ | ||
var path = process.env[key]; | ||
if(fis.util.exists(path) && !fis.util.isDir(path)){ | ||
fis.log.error('invalid environment variable [' + key + '] of document root [' + path + ']'); | ||
} | ||
return path; | ||
} else { | ||
return fis.project.getTempPath('www'); | ||
} | ||
})(); | ||
commander | ||
.option('-p, --port <int>', 'server listen port', parseInt, 8080) | ||
.option('--root <path>', 'document root', getRoot, fis.project.getTempPath('www')) | ||
.option('--root <path>', 'document root', getRoot, serverRoot) | ||
.option('--no-rewrite', 'disable rewrite feature', Boolean) | ||
@@ -326,3 +310,15 @@ .option('--script <name>', 'rewrite entry file name', String) | ||
var cmd = args.shift(); | ||
var conf = getConf(); | ||
var conf = getRCFile(); | ||
var root = options.root; | ||
if(root){ | ||
if(fis.util.exists(root) && !fis.util.isDir(root)){ | ||
fis.log.error('invalid document root [' + root + ']'); | ||
} else { | ||
fis.util.mkdir(root); | ||
} | ||
} else { | ||
fis.log.error('missing document root'); | ||
} | ||
switch (cmd){ | ||
@@ -376,2 +372,4 @@ case 'start': | ||
} | ||
} else { | ||
open(root); | ||
} | ||
@@ -382,8 +380,5 @@ break; | ||
var now = Date.now(); | ||
var root = options['root']; | ||
if(fis.util.isDir(root)){ | ||
var include = options.include ? fis.util.glob(root + '/' + options.include) : null; | ||
var exclude = options.exclude ? fis.util.glob(root + '/' + options.exclude) : /\/WEB-INF\//; | ||
fis.util.del(root, include, exclude); | ||
} | ||
var include = options.include ? fis.util.glob(root + '/' + options.include) : null; | ||
var exclude = options.exclude ? fis.util.glob(root + '/' + options.exclude) : /\/WEB-INF\//; | ||
fis.util.del(root, include, exclude); | ||
process.stdout.write((Date.now() - now + 'ms').green.bold); | ||
@@ -390,0 +385,0 @@ process.stdout.write('\n'); |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
4910947
383
5