Skip to content

Commit

Permalink
tweak checkEntry
Browse files Browse the repository at this point in the history
only check entry when there's no custom `run` process
  • Loading branch information
egoist committed Feb 5, 2017
1 parent 6cd53e3 commit 0c36158
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
13 changes: 5 additions & 8 deletions bin/vue-build
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ var options = merge({
})

function help () {
if (!options.entry) {
if (!options.run && !options.entry) {
return program.help()
}
}
Expand Down Expand Up @@ -300,16 +300,13 @@ if (!options.disableWebpackConfig) {
}
}

checkEntryExists(options.entry)
// only check entry when there's no custom `run` process
if (!options.run && !fs.existsSync(options.entry)) {
logger.fatal(`${chalk.yellow(options.entry)} does not exist, did you forget to create one?`)
}

run(webpackConfig, options)

function checkEntryExists (entry) {
if (!fs.existsSync(entry)) {
logger.fatal(`${chalk.yellow(entry)} does not exist, did you forget to create one?`)
}
}

function merge (obj) {
var i = 1
var target
Expand Down
8 changes: 5 additions & 3 deletions lib/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ var logger = require('./logger')
var createServer = require('../lib/server')

module.exports = function (webpackConfig, options) {
if (typeof options.run === 'function') {
return options.run(webpackConfig, options)
}

try {
var compiler = webpack(webpackConfig)
} catch (err) {
Expand All @@ -16,9 +20,7 @@ module.exports = function (webpackConfig, options) {
}
}

if (typeof options.run === 'function') {
options.run(webpackConfig, options)
} else if (options.watch) {
if (options.watch) {
console.log('> Running in watch mode')
rm(path.join(options.dist, '*'))
compiler.watch({}, (err, stats) => handleBuild(err, stats, true))
Expand Down

0 comments on commit 0c36158

Please sign in to comment.