Skip to content

Commit 3cdcd22

Browse files
committed
0.2.4
* 修复weexpack run web的bug 并且加了自动打开浏览器的功能
1 parent 52c1295 commit 3cdcd22

File tree

4 files changed

+22
-6
lines changed

4 files changed

+22
-6
lines changed

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ android的打包和构建是一体的 :
9999

100100
## changelog
101101

102+
0.2.4
103+
* 修复weexpack run web的bug 并且加了自动打开浏览器的功能
104+
102105
0.2.3
103106
* suppress adb reverse error(android 5.0- will cause error)
104107

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "weexpack",
3-
"version": "0.2.3",
3+
"version": "0.2.4",
44
"description": "Weex pack tool",
55
"main": "index.js",
66
"scripts": {
@@ -39,6 +39,7 @@
3939
"commander": "^2.9.0",
4040
"eslint": "^3.5.0",
4141
"inquirer": "^1.1.3",
42+
"opener": "^1.4.2",
4243
"recursive-copy": "^2.0.5",
4344
"yeoman-environment": "^1.6.3",
4445
"yeoman-generator": "^0.24.1"

src/run/server.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@ function startJSServer() {
1515
}
1616
if (!occupied) {
1717
try {
18-
child_process.exec(process.platform==='win32'?'start start.bat':`open ./start`, {encoding: 'utf8'});
18+
child_process.exec(process.platform==='win32'?'start start.bat':`open ./start`, {encoding: 'utf8'})
1919
}
2020
catch (e){
2121
console.error(e);
2222
}
23+
2324
}
25+
return occupied;
2426
}
2527

2628
module.exports = startJSServer

src/run/web.js

+14-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ const path = require('path')
33
const chalk = require('chalk')
44
const child_process = require('child_process')
55
const startJSServer = require('./server')
6-
6+
const util = require('../utils')
7+
const opener = require('opener');
78
/**
89
* Start web service
910
* @param {Object} options
@@ -20,9 +21,16 @@ function runWeb(options) {
2021
console.log()
2122
console.log(` => ${chalk.blue.bold('Starting web service')}`)
2223

24+
util.buildJS().then(function () {
25+
let exist = startJSServer();
26+
//没办法无法预知服务器啥时候完成
27+
setTimeout(function () {
28+
preview()
29+
}, exist ? 0 : 2000)
30+
31+
32+
})
2333

24-
startJSServer()
25-
preview()
2634
}
2735

2836
/**
@@ -31,7 +39,7 @@ function runWeb(options) {
3139
*/
3240
function checkWebEnv(cwd) {
3341
return fs.existsSync(path.join(cwd, 'package.json'))
34-
&& fs.existsSync(path.join(cwd, 'web'))
42+
&& fs.existsSync(path.join(cwd, 'web'))
3543
}
3644

3745
/**
@@ -40,6 +48,8 @@ function checkWebEnv(cwd) {
4048
function preview() {
4149
console.log(` => ${chalk.green('server is running')}`)
4250
console.log(` please open ${chalk.cyan('http://localhost:8080/web/index.html')}`)
51+
opener('http://localhost:8080/web/index.html');
52+
4353

4454
// open url in browser
4555
// try {

0 commit comments

Comments
 (0)