Skip to content

Commit

Permalink
Internalized browserify
Browse files Browse the repository at this point in the history
Run browserify dynamically, instead of once at start. Speeds up
development.
  • Loading branch information
vogonistic committed Feb 13, 2013
1 parent 13e24f9 commit 488860f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
8 changes: 8 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module.exports = init;

var child_process = require('child_process');

function init(mineflayer) {
return function(bot, options) { return inject(mineflayer, bot, options) };
}
Expand All @@ -16,7 +18,13 @@ function inject(mineflayer, bot, options) {

io.set('log level', 0);

app.use(express.logger());
app.use(express.static(path.join(__dirname, 'public')));
app.get('/client.js', function(req, res){
res.writeHead(200, {'Content-Type':'application/javascript'});
browserify = child_process.spawn('browserify', ['app.js']);
browserify.stdout.pipe(res);
});

server.listen(port, function() {
console.info("Listening at http://" + host + ":" + server.address().port);
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
"main": "index.js",
"author": "Kent Karlsson <vogonistic@gmail.com>",
"license": "BSD",
"dependencies": {
"devDependencies": {
"express": "~3.0.6",
"socket.io": "~0.9.13",
"browserify": "~1.17"
},
"dependencies": {
"vec3": "*",
"mineflayer": "*",
"mineflayer-navigate": "*",
Expand All @@ -16,7 +19,6 @@
"minecraft-skin": "*"
},
"scripts": {
"prestart": "browserify app.js -o public/client.js",
"start": "node run.js"
}
}

0 comments on commit 488860f

Please sign in to comment.