Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
} else if (/^git(\.exe)?/i.test(linter) && gitDir !== process.cwd()) {
// Only use gitDir as CWD if we are using the git binary
// e.g `npm` should run tasks in the actual CWD
execaOptions.cwd = gitDir
}
let cmd
let args
if (shell) {
execaOptions.shell = true
// If `shell`, passed command shouldn't be parsed
// If `linter` is a function, command already includes `pathsToLint`.
cmd = isFn ? linter : `${linter} ${pathsToLint.join(' ')}`
} else {
const [parsedCmd, ...parsedArgs] = stringArgv.parseArgsStringToArgv(linter)
cmd = parsedCmd
args = isFn ? parsedArgs : parsedArgs.concat(pathsToLint)
}
return ctx =>
execLinter(cmd, args, execaOptions).then(result => {
if (result.failed || result.killed || result.signal != null) {
throw makeErr(linter, result, ctx)
}
return successMsg(linter)
})
}
private static getCommandInfo(command: string, options: ISpawnOptions): { command: string, args: string[], options: ISpawnOptions } {
if (!command) command = '';
options = { ...options };
options.env = { ...options.env };
command = Executor.expandEnvironment(command, options.env);
if (!options.cwd) options.cwd = '';
let args = [];
if (!options.shell) {
args = parseArgsStringToArgv(command);
command = args[0];
args.shift();
}
if (command === '') {
console.log();
return { command: null, args, options };
}
if (command === 'echo') {
if (process.platform === 'win32') command += '.';
return { command, args, options };
}
public static parse(pattern: string): { command: string, arguments: string[] } {
const args = parseArgsStringToArgv(pattern);
return {
command: args.length > 0 ? args[0] : '',
arguments: args.slice(1),
};
}
private static convertSingleQuote(command: string): string {
const argv = parseArgsStringToArgv(command);
const result: string[] = [];
for (let value of argv) {
if (value.includes(' ')) value = '"' + value + '"';
result.push(value);
}
return result.join(' ');
}
if (!imageName) {
imageName = await dockerOpts.resolveRuntimeToDockerImage(runtime, true);
if (!imageName) {
throw new Error(`invalid runtime name ${runtime}`);
}
}
debug(`cmd: ${parseArgsStringToArgv(cmd || '')}`);
const container = await createContainer(dockerOpts.generateSboxOpts({
imageName,
hostname: `fc-${runtime}`,
mounts,
envs,
cmd: parseArgsStringToArgv(cmd || ''),
isTty,
isInteractive
}));
containers.add(container.id);
await container.start();
const stream = await container.attach({
logs: true,
stream: true,
stdin: isInteractive,
stdout: true,
stderr: true
});
);
} else {
return reject(res.error);
}
}
if (res.status != 0) {
return reject(res.stdout);
}
} else {
this.serverless.cli.log("Packaging gem dependencies...");
let args = ["install", "--path", "vendor/bundle"];
if (this.bundlerArgs) {
args.push(...stringArgv.parseArgsStringToArgv(this.bundlerArgs));
}
const res = child_process.spawnSync(this.bundlerBin, args);
if (res.error) {
if (res.error.code == "ENOENT") {
return reject(
`Unable to run Bundler executable: ${
this.bundlerBin
}. Use the "bundlerBin" option to set your Bundler executable explicitly.`
);
} else {
return reject(res.error);
}
}
if (res.status != 0) {
mounts, cmd, envs,
isTty, isInteractive
}) {
debug(`runtime: ${runtime}`);
debug(`mounts: ${mounts}`);
debug(`isTty: ${isTty}`);
debug(`isInteractive: ${isInteractive}`);
if (!imageName) {
imageName = await dockerOpts.resolveRuntimeToDockerImage(runtime, true);
if (!imageName) {
throw new Error(`invalid runtime name ${runtime}`);
}
}
debug(`cmd: ${parseArgsStringToArgv(cmd || '')}`);
const container = await createContainer(dockerOpts.generateSboxOpts({
imageName,
hostname: `fc-${runtime}`,
mounts,
envs,
cmd: parseArgsStringToArgv(cmd || ''),
isTty,
isInteractive
}));
containers.add(container.id);
await container.start();
const stream = await container.attach({