#!/usr/bin/env node 'use strict'; const co = require('co'); const program = require('commander'); const update = require('npm-update'); const pkg = require('../package.json'); const _ = require('../lib/common/helper'); const logger = require('../lib/common/logger'); const { chalk, sudoUserPermissionDenied } = _; sudoUserPermissionDenied(); const NoSmoke = require('..'); const options = { port: 5678, verbose: true }; const EOL = require('os').EOL; program .option('-p, --port ', 'port to use (5678 default)') .option('-u, --udid ', 'udid of device') .option('-a, --app ', 'path of app, will override the one specified in crawler.config.yml') .option('-h, --hooks ', 'location of the hook.js file') .option('-c, --config ', 'location of the configuration.yml file') .option('-s, --silent', 'start without opening browser') .option('-v, --versions', 'output version infomation') .option('--verbose', 'show more debugging information') .option('--server ', 'adddress for server: `http://127.0.01:3456`') .option('--duration ', 'timeout interval') .option('--deviceName ', 'name of device') .option('--deviceType ', 'type of device') .usage(''); program.parse(process.argv); var printInfo = function(lines) { var maxLength = 0; lines.forEach(line => { maxLength = line.length > maxLength ? line.length : maxLength; }); var res = [new Array(maxLength + 7).join('*')]; lines.forEach(line => { res.push(`* ${line + new Array(maxLength - line.length + 1).join(' ')} *`); }); res.push(new Array(maxLength + 7).join('*')); console.log(chalk.white(`${EOL}${res.join(EOL)}${EOL}`)); }; function init(error, data) { if (program.versions) { console.info(`${EOL} ${chalk.grey(pkg.version)} ${EOL}`); process.exit(0); } _.merge(options, _.getConfig(program)); co(NoSmoke, options).catch(e => { console.log(e); }); } co(update, { pkg: pkg, callback: init });