Skip to content

Commit

Permalink
MOD: 开启 weinre 服务器
Browse files Browse the repository at this point in the history
  • Loading branch information
wulijian committed Jul 28, 2015
1 parent a9e671b commit 2c482db
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
11 changes: 1 addition & 10 deletions bin/kkit
Expand Up @@ -148,16 +148,7 @@ Dispatcher.handlers = {
runner.startHttpServer(process.cwd(), httpPort, templateRoot);
},
'weinre': function () {
//run weinre at httpPort setted
var weinre = path.resolve(__dirname, '../node_modules/weinre');
var lib = path.join(weinre, 'lib');
process.argv.pop();
process.argv.pop();
('--httpPort ' + weinrePort + ' --boundHost -all-').split(' ').forEach(function (val) {
process.argv.push(val);
});
var node_modules = path.join(weinre, 'node_modules');
require(path.join(lib, '/cli')).run();
runner.startWeinreServer(weinrePort);
},
'all': function () {
this['http']();
Expand Down
23 changes: 23 additions & 0 deletions lib/runner/index.js
Expand Up @@ -10,6 +10,7 @@ var path = require('path');
var fs = require('fs');
require("consoleplusplus");
var config = require('../config')();
var weinreStarted = false;

/**
* 自动重新编译被修改的模块
Expand Down Expand Up @@ -84,6 +85,10 @@ var responsePageMapping = function (rootpath, req, res, next) {
return next();
} else {
var code = inc.include(relPath, puz.puz(relPath));
if (weinreStarted) {
code = code + '<script type="text/javascript" src="http://' + require('../ip').address()
+ ':10089/target/target-script-min.js#anonymous"></script>'
}
if (code !== null) {
res.end(code);
} else {
Expand Down Expand Up @@ -117,3 +122,21 @@ exports.startHttpServer = function (rootpath, httpPort, templateRoot) {
con.listen(httpPort);
console.info('start http server at #yellow{http://localhost:' + httpPort + '}');
};
/**
* 开启 weinreserver
* @param port 端口号
*/
exports.startWeinreServer = function (port) {
weinreStarted = true;
//run weinre at httpPort setted
var weinre = path.resolve(__dirname, '../../node_modules/weinre');
var lib = path.join(weinre, 'lib');
process.argv.pop();
process.argv.pop();
('--httpPort ' + port + ' --boundHost -all-').split(' ').forEach(function (val) {
process.argv.push(val);
});
var node_modules = path.join(weinre, 'node_modules');
require(path.join(lib, '/cli')).run();
console.info('start http server at #yellow{http://localhost:' + port + '}');
};

0 comments on commit 2c482db

Please sign in to comment.