1
1
mirror of https://github.com/c8r/x0.git synced 2024-09-19 09:38:31 +03:00

Merge pull request #24 from mike3run/master

open in browser but only once
This commit is contained in:
Brent Jackson 2017-12-16 19:07:43 +00:00 committed by GitHub
commit bd4e0907d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 6 deletions

View File

@ -2,7 +2,7 @@
const path = require('path')
const meow = require('meow')
const { pkg } = require('read-pkg-up').sync()
const open = require('opn')
const openBrowser = require('react-dev-utils/openBrowser')
const ora = require('ora')
const chalk = require('chalk')
@ -57,15 +57,13 @@ const spinner = ora().start()
switch (cmd) {
case 'dev':
spinner.start('starting dev server')
let opened = false
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 (!opened && options.open) {
open(`http://localhost:${port}`)
opened = true
if (options.open) {
openBrowser(`http://localhost:${port}`)
}
})
.catch(err => {

View File

@ -30,10 +30,10 @@
"glamor": "^2.20.40",
"glamorous": "^4.11.0",
"meow": "^3.7.0",
"opn": "^5.1.0",
"ora": "^1.3.0",
"pkg-up": "^2.0.0",
"react": "^16.2.0",
"react-dev-utils": "^4.2.1",
"react-dom": "^16.2.0",
"react-fela": "^6.1.1",
"read-pkg-up": "^2.0.0",