npm-java-runner
Advanced tools
@@ -10,15 +10,38 @@ #!/usr/bin/env node | ||
var fs_1 = __importDefault(require("fs")); | ||
var child_process_1 = __importDefault(require("child_process")); | ||
function execute(command) { | ||
child_process_1.default.exec(command, function (error, stdout, stderr) { | ||
if (error) { | ||
console.error(error); | ||
var shelljs_1 = require("shelljs"); | ||
function executeJar(jarFile) { | ||
var userArgs = process.argv.slice(2); | ||
var javaArgs = []; | ||
var programArgs = []; | ||
userArgs.forEach(function (arg) { | ||
if (arg.startsWith('-D') || arg.startsWith('-X') || arg.startsWith('-P')) { | ||
javaArgs.push(arg); | ||
} | ||
if (stderr) { | ||
console.error(stderr); | ||
else { | ||
programArgs.push(arg); | ||
} | ||
if (stdout) { | ||
console.log(stdout); | ||
}); | ||
var cmd = 'java'; | ||
javaArgs.forEach(function (arg) { | ||
cmd += " " + arg; | ||
}); | ||
cmd += " -jar " + jarFile + " "; | ||
programArgs.forEach(function (arg) { | ||
cmd += " " + arg; | ||
}); | ||
var child = shelljs_1.exec(cmd, { async: true }); | ||
process.stdin.setEncoding('utf8'); | ||
process.stdin.on('readable', function () { | ||
var chunk = process.stdin.read(); | ||
if (chunk === null) { | ||
return; | ||
} | ||
try { | ||
child.stdin.write(chunk); | ||
} | ||
catch (e) { } | ||
}); | ||
child.on('close', function (code) { | ||
process.exit(code); | ||
}); | ||
} | ||
@@ -56,5 +79,5 @@ function search(dir, regex) { | ||
var runnableJar = resolveRunnableJar(runnableJarRegexp, userPath); | ||
execute("java -jar " + runnableJar); | ||
executeJar(runnableJar); | ||
} | ||
exports.run = run; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "npm-java-runner", | ||
"version": "0.0.10", | ||
"version": "0.0.11", | ||
"scripts": { | ||
@@ -10,3 +10,5 @@ "build": "npm run format && tsc -p .", | ||
"dependencies": { | ||
"path": "^0.12.7" | ||
"@types/shelljs": "^0.8.9", | ||
"path": "^0.12.7", | ||
"shelljs": "^0.8.4" | ||
}, | ||
@@ -13,0 +15,0 @@ "devDependencies": { |
Sorry, the diff of this file is not supported yet
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
6916
28.12%82
38.98%0
-100%3
200%