mirror of
https://github.com/c8r/x0.git
synced 2024-09-11 21:57:26 +03:00
Make dev mode the default
This commit is contained in:
parent
c57babe8b5
commit
c04b4e1010
@ -32,7 +32,7 @@ npm install -g @compositor/x0
|
||||
## Isolated development environment
|
||||
|
||||
```sh
|
||||
x0 dev src/App.js
|
||||
x0 src/App.js
|
||||
```
|
||||
|
||||
Options:
|
||||
@ -43,7 +43,7 @@ Options:
|
||||
```
|
||||
|
||||
```sh
|
||||
x0 dev src/App.js -op 8080
|
||||
x0 src/App.js -op 8080
|
||||
```
|
||||
|
||||
|
||||
|
36
bin/cli.js
36
bin/cli.js
@ -52,28 +52,12 @@ const absolute = f => f
|
||||
? path.isAbsolute(f) ? f : path.join(process.cwd(), f)
|
||||
: null
|
||||
|
||||
const filename = absolute(file)
|
||||
const filename = absolute(file || cmd)
|
||||
|
||||
console.log(chalk.black.bgCyan(' x0 '), chalk.cyan('@compositor/x0'), '\n')
|
||||
const spinner = ora().start()
|
||||
|
||||
switch (cmd) {
|
||||
case 'dev':
|
||||
spinner.start('starting dev server')
|
||||
const dev = require('../lib/dev')
|
||||
dev(filename, options)
|
||||
.then(server => {
|
||||
const { port } = server.listeningApp.address()
|
||||
spinner.succeed(`dev server listening at http://localhost:${port}`)
|
||||
if (options.open) {
|
||||
openBrowser(`http://localhost:${port}`)
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
spinner.fail(err)
|
||||
process.exit(1)
|
||||
})
|
||||
break
|
||||
case 'build':
|
||||
spinner.start('building static site')
|
||||
const build = require('../lib/static')
|
||||
@ -91,7 +75,21 @@ switch (cmd) {
|
||||
process.exit(1)
|
||||
})
|
||||
break
|
||||
case 'dev':
|
||||
default:
|
||||
spinner.fail('no argument provided')
|
||||
process.exit(0)
|
||||
spinner.start('starting dev server')
|
||||
const dev = require('../lib/dev')
|
||||
dev(filename, options)
|
||||
.then(server => {
|
||||
const { port } = server.listeningApp.address()
|
||||
spinner.succeed(`dev server listening at http://localhost:${port}`)
|
||||
if (options.open) {
|
||||
openBrowser(`http://localhost:${port}`)
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
spinner.fail(err)
|
||||
process.exit(1)
|
||||
})
|
||||
break
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
"x0": "bin/cli.js"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "./bin/cli.js dev docs/App.js -op 8888",
|
||||
"start": "./bin/cli.js docs/App.js -op 8888",
|
||||
"static": "./bin/cli.js build docs/App.js --static -d docs",
|
||||
"build": "./bin/cli.js build docs/App.js -d docs -c docs/webpack.config.js",
|
||||
"test": "nyc ava",
|
||||
|
Loading…
Reference in New Issue
Block a user