Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const normalizedEnv: {[key: string]: string} = {};
for (const [key, value] of Object.entries(env))
if (typeof value !== `undefined`)
normalizedEnv[key] = value;
const normalizedBuiltins = new Map(BUILTINS);
for (const [key, builtin] of Object.entries(builtins))
normalizedBuiltins.set(key, builtin);
// This is meant to be the equivalent of /dev/null
if (stdin === null) {
stdin = new PassThrough();
(stdin as PassThrough).end();
}
const ast = parseShell(command);
// If the shell line doesn't use the args, inject it at the end of the
// right-most command
if (!locateArgsVariable(ast) && ast.length > 0 && args.length > 0) {
let command = ast[ast.length - 1];
while (command.then)
command = command.then.line;
let chain = command.chain;
while (chain.then)
chain = chain.then.chain;
if (chain.type === `command`) {
chain.args = chain.args.concat(args.map(arg => {
return {
type: `argument` as 'argument',