Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return (command, opts = {}) => {
exec(command, {
dir,
...opts,
});
};
}
command,
dir,
dryRun = false,
printCommand = true,
silent = false,
}) => {
if (!dir) {
throw new Error('`dir` is missing');
}
if (printCommand) {
print(`$ ${command}`);
}
if (dryRun) {
return;
}
const { code } = exec(command, { dir, silent });
if (code !== 0) {
if (printCommand) {
print(error('The following command failed:'));
print(` > ${command}`);
} else {
print(error('Command failed'));
}
exitProcess(1);
}
};