mirror of
https://github.com/github/codeql.git
synced 2025-12-17 17:23:36 +01:00
22 lines
504 B
JavaScript
22 lines
504 B
JavaScript
const cp = require('child_process'),
|
|
http = require('http'),
|
|
url = require('url');
|
|
|
|
function getShell() {
|
|
if (process.platform === 'win32') {
|
|
return { cmd: 'cmd', arg: '/C' }
|
|
} else {
|
|
return { cmd: 'sh', arg: '-c' }
|
|
}
|
|
}
|
|
|
|
function execSh(command, options) {
|
|
var shell = getShell()
|
|
return cp.spawn(shell.cmd, [shell.arg, command], options) // BAD
|
|
}
|
|
|
|
http.createServer(function (req, res) {
|
|
let cmd = url.parse(req.url, true).query.path;
|
|
execSh(cmd);
|
|
});
|