Skip to content

Commit

Permalink
fix: proper minimum node version warning
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Apr 16, 2018
1 parent 7d0586f commit eb07685
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
20 changes: 6 additions & 14 deletions bin/vuepress.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ const requiredVersion = require('../package.json').engines.node

if (!semver.satisfies(process.version, requiredVersion)) {
console.log(chalk.red(
`You are using Node ${process.version}, but VuePress ` +
`requires Node ${requiredVersion}.\nPlease upgrade your Node version.`
`\n[vuepress] minimum Node version not met:` +
`\nYou are using Node ${process.version}, but VuePress ` +
`requires Node ${requiredVersion}.\nPlease upgrade your Node version.\n`
))
process.exit(1)
}

const path = require('path')
const { dev, build } = require('../lib')
const { dev, build, eject } = require('../lib')

const program = require('commander')

Expand Down Expand Up @@ -41,17 +42,8 @@ program
program
.command('eject [targetDir]')
.description('copy the default theme into .vuepress/theme for customization.')
.action(async (dir = '.') => {
const fs = require('fs-extra')
const source = path.resolve(__dirname, '../lib/default-theme')
const target = path.resolve(dir, '.vuepress/theme')
await fs.copy(source, target)
// remove the import to default theme override
const styleConfig = path.resolve(target, 'styles/config.styl')
const content = await fs.readFile(styleConfig, 'utf-8')
const transformed = content.split('\n').slice(0, -2).join('\n')
await fs.writeFile(styleConfig, transformed)
console.log(`Copied default theme into ${chalk.cyan(target)}.`)
.action((dir = '.') => {
wrapCommand(eject)(path.resolve(dir))
})

// output help information on unknown commands
Expand Down
15 changes: 15 additions & 0 deletions lib/eject.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const fs = require('fs-extra')
const path = require('path')
const chalk = require('chalk')

module.exports = async (dir) => {
const source = path.resolve(__dirname, 'default-theme')
const target = path.resolve(dir, '.vuepress/theme')
await fs.copy(source, target)
// remove the import to default theme override
const styleConfig = path.resolve(target, 'styles/config.styl')
const content = await fs.readFile(styleConfig, 'utf-8')
const transformed = content.split('\n').slice(0, -2).join('\n')
await fs.writeFile(styleConfig, transformed)
console.log(`Copied default theme into ${chalk.cyan(target)}.`)
}
1 change: 1 addition & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
exports.dev = require('./dev')
exports.build = require('./build')
exports.eject = require('./eject')
Object.assign(exports, require('./util'))

0 comments on commit eb07685

Please sign in to comment.