Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function parse(a: string): string {
if (a.startsWith('"')) {
a = a.replace(/\\n/g, '\n')
} else if (a.startsWith("'")) {
a = a.replace(/\\\\/g, '\\')
}
let parsed = shell.parse(a)
if (parsed.length > 1) throw new Error(`Invalid token: ${a}`)
return parsed[0]
// return parsed[0].replace(/\\\\n/g, '\n')
}
Runner.prototype.execFn = function(cmd) {
var self = this;
var args = require('shell-quote').parse(cmd);
var bin = args.shift(0);
return function(fn) {
// Allow .run('') without attempting
if (cmd === '') { fn(undefined); return; }
var child = spawn(bin, args, self.world);
var stdout = '';
var stderr = '';
var err;
if (self.standardInput != null) {
child.stdin.end(self.standardInput);
}
if (self.world.timeout) {
.map(input => {
try {
return evalChain(data, parseArgs(parse(input)));
} catch(e) { /* */ }
});
function guessEditor() {
// Explicit config always wins
if (process.env.REACT_EDITOR) {
return shellQuote.parse(process.env.REACT_EDITOR);
}
// We can find out which editor is currently running by:
// `ps x` on macOS and Linux
// `Get-Process` on Windows
try {
if (process.platform === 'darwin') {
const output = child_process.execSync('ps x').toString();
const processNames = Object.keys(COMMON_EDITORS_OSX);
for (let i = 0; i < processNames.length; i++) {
const processName = processNames[i];
if (output.indexOf(processName) !== -1) {
return [COMMON_EDITORS_OSX[processName]];
}
}
} else if (process.platform === 'win32') {
.forEach(function (c) {
var cmd = parseShell(c);
b.transform(function (file) {
var env = Object.keys(process.env).reduce(function (acc, key) {
acc[key] = process.env[key];
return acc;
}, {});
env.FILENAME = file;
var ps = spawn(cmd[0], cmd.slice(1), { env: env });
var error = '';
ps.stderr.on('data', function (buf) { error += buf });
ps.on('exit', function (code) {
if (code === 0) return;
console.error([
'error running source transform command: ' + c,
error.split('\n').join('\n '),
''
function expandVariable(variable: string | undefined): string[] {
if (variable) {
outputChannel.appendLine("Using JAVA options set in JAVA_OPTS");
return parse(variable).filter(
(entry): entry is string => {
if (typeof entry === "string") {
return true;
} else {
outputChannel.appendLine(
`Ignoring unexpected JAVA_OPTS token: ${entry}`
);
return false;
}
}
);
} else {
return [];
}
}
const javaOpts = expandVariable(process.env.JAVA_OPTS);
async $invoke(_expression, {owner} = {}) {
const expressions = this.$expressions || [];
let result;
for (let expression of expressions) {
const args = parse(expression, variable => '$' + variable);
expression = parseCommandLineArguments(args);
result = await this._invokeExpression(expression, {owner});
}
return result;
}
return this._lockApplication(application, () => {
var terminal = this._terminals[application.name];
if (terminal) return;
var env = _.defaults({}, application.env, {
PORT: application.port
});
var xs = ShellQuote.parse(application.command, env);
var executable = xs[0];
var args = xs.slice(1);
var spawnCmd = executable;
var spawnArgs = args;
var startTime;
var envPath = _.compact([env["PATH"], env["Path"]]).join(Path.delimiter);
if (Os.platform() == "win32") {
spawnCmd = env["COMSPEC"];
spawnArgs = ["/C", ...xs];
}
return Promise.resolve()
.then(() => Utility.stat(application.dir))
.then(
stat =>
module.exports = function cmd(opts) {
const argv = require('minimist')(parse(opts.text));
const response_url = opts.response_url;
return new Promise((resolve, reject) => {
switch (argv._[0]) {
case "find":
const id = argv._[1];
if (!id) {
resolve('Usage: /jira find [id]');
} else {
resolve(`Locating JIRA issue ${id}...`);
module.exports.find(id, (err, issue) => {
let response = {};
if (err) {