All files / src index.ts

92.86% Statements 13/14
100% Branches 2/2
100% Functions 1/1
92.86% Lines 13/14

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25  1x   1x 4x 4x 2x 2x     2x 2x 1x   1x 1x     1x         1x  
 
import log from './utils/log';
 
export const cli = async (args) => {
  const [command] = args.slice(2);
  if (!command) {
    log.error('Provide command');
    return;
  }
 
  try {
    const commandFn = require(`./commands/${command}.ts`);
    return commandFn.default(args.slice(3));
  } catch (err) {
    try {
      const commandFn = require(`./commands/${command}.js`);
      return commandFn.default(args.slice(3));
    } catch (err) {
      log.error('Bad command');
    }
  }
};
 
cli(process.argv);