all files / commanders/baidu/ 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                                                                                                       
 
exports.name = 'baidu';
exports.usage = '[command] [options]';
exports.desc = 'tools for the baidu miniprogram 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'
          ]
        }]
        inquirer.prompt(questions).then(answers => {
          handlerCmd(answers.type)
        })
      }
 
      function handlerCmd (cmd) {
        cml.media = cmd;
        utils.startReleaseOne(cmd, 'baidu');
      }
 
    })
 
  commander.on('--help', function() {
    var cmd = `
  Commands:
    dev      develop the project for weixin miniprogram
    build    build the project for weixin miniprogram
  Examples:
    cml wx dev
    cml wx build
    `
    console.log(cmd)
  })
 
}