mirror of
https://github.com/ershisan99/go-npm.git
synced 2025-12-17 05:09:30 +00:00
29 lines
761 B
JavaScript
29 lines
761 B
JavaScript
const actions = {
|
|
install: (callback) => require('./actions/install')(callback),
|
|
uninstall: (callback) => require('./actions/uninstall')(callback)
|
|
};
|
|
|
|
// Parse command line arguments and call the right action
|
|
module.exports = ({ argv, exit }) => {
|
|
if (argv && argv.length > 2) {
|
|
const cmd = argv[2];
|
|
|
|
if (!actions[cmd]) {
|
|
console.log('Invalid command to go-npm. `install` and `uninstall` are the only supported commands');
|
|
exit(1);
|
|
} else {
|
|
actions[cmd]((err) => {
|
|
if (err) {
|
|
console.error(err);
|
|
exit(1);
|
|
} else {
|
|
exit(0);
|
|
}
|
|
});
|
|
}
|
|
} else {
|
|
console.log('No command supplied. `install` and `uninstall` are the only supported commands');
|
|
exit(1);
|
|
}
|
|
};
|