all files / commanders/weex/ index.js

31.82% Statements 7/22
0% Branches 0/2
25% Functions 1/4
31.82% Lines 7/22
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 52 53 54 55 56 57 58 59 60 61 62                                                                                                             
 
 
exports.name = 'weex';
exports.usage = '[command] [options]';
exports.desc = 'tools for the weex project';
 
exports.register = function (commander) {
  commander
    .option('-r, --root [root]', 'specify project root')
    .action(function (...args) {
      cml.utils.checkProjectConfig();
      /* eslint-disable */
      cml.log.startBuilding();
      const inquirer = require('inquirer');
      const utils = require('../utils.js');
      /* eslint-disable */
      // 不能删除
      var options = args.pop(); // eslint-disable-line
 
      var cmd = args.shift();
 
      if (cmd) {
        handlerCmd(cmd);
      } else {
        let questions = [{
          type: 'list',
          name: 'type',
          message: 'Which do you want to do?',
          choices: [
            'dev',
            'build',
            'proxy'
          ]
        }]
        inquirer.prompt(questions).then(answers => {
          handlerCmd(answers.type)
        })
      }
 
      function handlerCmd(cmd) {
        cml.media = cmd;
        utils.startReleaseOne(cmd, 'weex');
 
      }
 
 
    })
  commander.on('--help', function() {
    var cmd = `
  Commands:
    dev     develop the project for weex 
    build   build the project for weex 
  Examples:
    cml weex dev
    cml weex build
    `
    console.log(cmd)
  })
 
}