mirror of
https://github.com/c8r/x0.git
synced 2024-09-11 21:57:26 +03:00
Fix cli dev mode options
This commit is contained in:
parent
94f806cd61
commit
c9e9d59b50
@ -2,6 +2,7 @@
|
||||
const path = require('path')
|
||||
const meow = require('meow')
|
||||
const { pkg } = require('read-pkg-up').sync()
|
||||
const open = require('opn')
|
||||
|
||||
require('update-notifier')({
|
||||
pkg: require('../package.json')
|
||||
@ -28,6 +29,8 @@ const cli = meow(`
|
||||
|
||||
`, {
|
||||
alias: {
|
||||
o: 'open',
|
||||
p: 'port',
|
||||
d: 'outDir'
|
||||
}
|
||||
})
|
||||
@ -45,7 +48,10 @@ switch (cmd) {
|
||||
case 'dev':
|
||||
const dev = require('../lib/dev')
|
||||
dev(filename, options, (err, port) => {
|
||||
console.log(port)
|
||||
console.log(`Development server listening at http://localhost:${port}`)
|
||||
if (options.open) {
|
||||
open(`http://localhost:${port}`)
|
||||
}
|
||||
})
|
||||
break
|
||||
case 'build':
|
||||
|
@ -1,7 +1,6 @@
|
||||
const path = require('path')
|
||||
const webpack = require('webpack')
|
||||
const DevServer = require('webpack-dev-server')
|
||||
const open = require('opn')
|
||||
const config = require('./config')
|
||||
|
||||
const devOptions = {
|
||||
@ -42,13 +41,7 @@ module.exports = (filename, options = {}, cb) => {
|
||||
|
||||
const server = new DevServer(compiler, devOptions)
|
||||
|
||||
let opened = false
|
||||
compiler.plugin('done', () => {
|
||||
// if (options.open && !opened) {
|
||||
if (!opened) {
|
||||
open(`http://localhost:${port}`)
|
||||
opened = true
|
||||
}
|
||||
if (typeof cb === 'function') cb(null, port)
|
||||
})
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
"x0": "bin/cli.js"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "./bin/cli.js dev docs/App.js",
|
||||
"start": "./bin/cli.js dev docs/App.js -op 8888",
|
||||
"build": "./bin/cli.js build docs/App.js",
|
||||
"test": "./bin/cli.js build docs/App.js --html docs/Root.js -d docs"
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user