Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function checkPermission (filename) {
try {
if (!executable.sync(filename)) {
return errorAndExit(`Script "${filename}" is not executable`)
}
} catch (err) {
return errorAndExit(`Script "${filename}" does not exist`)
}
}
var runPrePostScript = function(scriptPath, params) {
try {
if (executable.sync(scriptPath)) {
child_process.spawnSync(scriptPath, params);
} else {
winston.error("The specified script is not executable");
}
}
catch (e) {
winston.error("The specified script doesn't exist");
}
};
module.exports.sync = (bin, args) => {
if (!Array.isArray(args)) {
args = ['--help'];
}
if (!executable.sync(bin)) {
throw new Error(`Couldn't execute the \`${bin}\` binary. Make sure it has the right permissions.`);
}
return execa.sync(bin, args).status === 0;
};