UNPKG

715 BJavaScriptView Raw
1"use strict";
2const path_1 = require('path');
3const usage_1 = require('./actions/usage');
4module.exports = (command, args, options) => {
5 const commandFile = path_1.resolve(__dirname, `commands/${command}`);
6 let HandlerFunction;
7 try {
8 HandlerFunction = require(commandFile).default;
9 }
10 catch (e) {
11 console.error(`unknown command "${command}"`);
12 console.error(`\t${e.message}`);
13 throw usage_1.default();
14 }
15 const ret = HandlerFunction.apply(options, args);
16 if (ret === true || ret === undefined) {
17 return 0;
18 }
19 else if (ret === false) {
20 return 1;
21 }
22 else {
23 return ret;
24 }
25};
26//# sourceMappingURL=run_command.js.map
\No newline at end of file