Merge pull request #42 from nasa/reload-bundles-on-pageload

[Development] Reload bundle file with each request
This commit is contained in:
Victor Woeltjen 2015-07-01 13:19:21 -07:00
commit 4c77dd6a69

9
app.js
View File

@ -14,8 +14,7 @@
options = require('minimist')(process.argv.slice(2)),
express = require('express'),
app = express(),
fs = require('fs'),
bundles = JSON.parse(fs.readFileSync(BUNDLE_FILE, 'utf8'));
fs = require('fs');
// Defaults
options.port = options.port || options.p || 8080;
@ -40,6 +39,10 @@
process.exit(0);
}
// Override bundles.json for HTTP requests
app.use('/' + BUNDLE_FILE, function (req, res) {
var bundles = JSON.parse(fs.readFileSync(BUNDLE_FILE, 'utf8'));
// Handle command line inclusions/exclusions
bundles = bundles.concat(options.include);
bundles = bundles.filter(function (bundle) {
@ -49,8 +52,6 @@
return bundles.indexOf(bundle) === index;
});
// Override bundles.json for HTTP requests
app.use('/' + BUNDLE_FILE, function (req, res) {
res.send(JSON.stringify(bundles));
});