mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-13 12:29:42 +02:00
Replace require with import
This commit is contained in:
20
lib/cli.js
20
lib/cli.js
@@ -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
|
||||
|
Reference in New Issue
Block a user