mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 06:56:24 +00:00
32 lines
722 B
JavaScript
32 lines
722 B
JavaScript
import commander from 'commander';
|
|
import shell from 'shelljs';
|
|
|
|
const program = new commander.Command();
|
|
program
|
|
.version('0.0.1')
|
|
.requiredOption('-r, --release <type>', 'Version to use')
|
|
.option('-s, --sha <type>', 'Sha to use')
|
|
.option('-d, --dry-run');
|
|
|
|
program.parse(process.argv);
|
|
|
|
export { program };
|
|
|
|
/**
|
|
* Executes a shell command
|
|
* @param cmd {string} The command to execute
|
|
* @returns {boolean} Returns true on zero exit code otherwise false
|
|
*/
|
|
export function exec(cmd) {
|
|
try {
|
|
if (!program.dryRun) {
|
|
const res = shell.exec(cmd);
|
|
return res.code === 0;
|
|
}
|
|
shell.echo(`DRY-RUN: ${cmd}`);
|
|
} catch (e) {
|
|
shell.echo(e.toString());
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|