Skip to content

Commit

Permalink
0.2.4
Browse files Browse the repository at this point in the history
* 修复weexpack run web的bug 并且加了自动打开浏览器的功能
  • Loading branch information
exolution committed Dec 16, 2016
1 parent 52c1295 commit 3cdcd22
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ android的打包和构建是一体的 :

## changelog

0.2.4
* 修复weexpack run web的bug 并且加了自动打开浏览器的功能

0.2.3
* suppress adb reverse error(android 5.0- will cause error)

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "weexpack",
"version": "0.2.3",
"version": "0.2.4",
"description": "Weex pack tool",
"main": "index.js",
"scripts": {
Expand Down Expand Up @@ -39,6 +39,7 @@
"commander": "^2.9.0",
"eslint": "^3.5.0",
"inquirer": "^1.1.3",
"opener": "^1.4.2",
"recursive-copy": "^2.0.5",
"yeoman-environment": "^1.6.3",
"yeoman-generator": "^0.24.1"
Expand Down
4 changes: 3 additions & 1 deletion src/run/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ function startJSServer() {
}
if (!occupied) {
try {
child_process.exec(process.platform==='win32'?'start start.bat':`open ./start`, {encoding: 'utf8'});
child_process.exec(process.platform==='win32'?'start start.bat':`open ./start`, {encoding: 'utf8'})
}
catch (e){
console.error(e);
}

}
return occupied;
}

module.exports = startJSServer
18 changes: 14 additions & 4 deletions src/run/web.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ const path = require('path')
const chalk = require('chalk')
const child_process = require('child_process')
const startJSServer = require('./server')

const util = require('../utils')
const opener = require('opener');
/**
* Start web service
* @param {Object} options
Expand All @@ -20,9 +21,16 @@ function runWeb(options) {
console.log()
console.log(` => ${chalk.blue.bold('Starting web service')}`)

util.buildJS().then(function () {
let exist = startJSServer();
//没办法无法预知服务器啥时候完成
setTimeout(function () {
preview()
}, exist ? 0 : 2000)


})

startJSServer()
preview()
}

/**
Expand All @@ -31,7 +39,7 @@ function runWeb(options) {
*/
function checkWebEnv(cwd) {
return fs.existsSync(path.join(cwd, 'package.json'))
&& fs.existsSync(path.join(cwd, 'web'))
&& fs.existsSync(path.join(cwd, 'web'))
}

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


// open url in browser
// try {
Expand Down

0 comments on commit 3cdcd22

Please sign in to comment.