All files / lib script.js

57.69% Statements 15/26
33.33% Branches 3/9
100% Functions 2/2
57.69% Lines 15/26

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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 521x 1x 1x 1x 1x 1x   1x 1x                 1x                 1x 1x 1x 1x   1x 1x                                      
const arg = require('arg');
const buildCmd = require('./build/build');
const publishCmd = require('./publish/publish');
const deleteCmd = require('./delete/delete');
const listCmd = require('./list/list');
const devServerCmd = require('./dev-server-asset/dev-server');
 
const parseArgumentsIntoOptions = rawArgs => {
  const args = arg(
    {
      '--install': Boolean,
      '--skipBundle': Boolean
    },
    {
      argv: rawArgs.slice(2)
    }
  );
  return {
    cmd: args._[0],
    git: true, // args['--git'] || false
    runInstall: true, // args['--install'] || false
    skipBundle: args['--skipBundle'] || false,
    params: rawArgs
  };
};
 
exports.excuteCmd = function (args) {
  const options = parseArgumentsIntoOptions(args);
  let { params } = options;
  switch (params) {
    case 'build':
      buildCmd.buildLib()
      break;
    case 'build-v3':
      buildCmd.buildLibV3()
      break;
    case 'publish':
      publishCmd.publishLib()
      break;
    case 'delete':
      deleteCmd.deleteLib();
      break;
    case 'list':
      listCmd.listLib();
      break;
    case 'dev-server':
      devServerCmd.devServerStart();
      break;
    default:
      process.exit();
  }
};