forked from aframevr/aframe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
budo.js
49 lines (43 loc) · 1.31 KB
/
budo.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env node
var exec = require('child_process').exec;
var urlParse = require('url').parse;
var budo = require('budo');
function execCmd (cmd) {
var p = exec(cmd);
p.stderr.pipe(process.stderr);
p.stdout.pipe(process.stdout);
return p;
}
var consts = {
NAME: 'AFRAME',
ENTRY: './src/index.js',
DIST: 'dist/aframe-master.js',
BUILD: 'build/aframe-master.js',
WATCH: 'examples/**/*', // Additional files to watch for LiveReload
PORT: 9000
};
var opts = {
debug: process.env.NODE_ENVIRONMENT !== 'production',
verbose: true,
live: true,
stream: process.stdout,
host: process.env.HOST,
port: process.env.PORT || consts.PORT,
watchGlob: consts.WATCH,
browserifyArgs: ['-s', consts.NAME],
middleware: function (req, res, next) {
// Route `dist/aframe-master.js` to `build/aframe-master.js` so we can
// dev against the examples :)
var path = urlParse(req.url).pathname;
if (path.indexOf('/' + consts.DIST) !== -1) {
req.url = req.url.replace('/dist/', '/build/');
}
// TODO: Consider adding middleware that targets specific directories
// (such that editing `examples/a.html` doesn't reload `examples/b.html`).
next();
}
};
var app = budo(consts.ENTRY + ':' + consts.BUILD, opts);
app.on('update', function () {
execCmd('semistandard -v | snazzy');
});