Replace require with import

This commit is contained in:
Tyler Long
2017-09-10 21:23:04 +08:00
parent c9442653e9
commit a7d79baf00
36 changed files with 693 additions and 838 deletions

View File

@@ -4,17 +4,15 @@ import which from 'which'
import parseArgs from 'minimist'
import semver from 'semver'
import path from 'path'
import { exec } from 'child_process'
import phantom from 'phantomjs'
var exec = require('child_process').exec
import pkg from '../package.json'
var PHANTOM_VERSION = '^2.1.0'
var PHANTOM_VERSION = '^2.1.15'
var info = chalk.blue.bold
module.exports = (function () {
return new Cli()
}())
function Cli (options) {
this.options = {
alias: {
@@ -63,9 +61,7 @@ function Cli (options) {
Cli.prototype.parse = function (argv, next) {
this.errors = [] // clear errors
var options = parseArgs(argv, this.options)
if (options.version) {
var pkg = require('../package.json')
this.message = '' + pkg.version
next(null, this.message)
} else if (options.help) {
@@ -151,10 +147,8 @@ function createCheckPhantom (_phantomPath) {
return function checkPhantom (_next) {
var next = _next || function () { }
var err
if (typeof phantomPath === 'undefined') {
try {
var phantom = require('phantomjs')
phantomPath = phantom.path
} catch (e) {
try {
@@ -195,3 +189,9 @@ function createCheckPhantom (_phantomPath) {
})
}
}
const cli = (function () {
return new Cli()
}())
export default cli