Merge pull request #893 from nasa/open885

#885 added command line option --directory -D to specify base directory
This commit is contained in:
Victor Woeltjen 2016-05-06 10:19:44 -07:00
commit d6aa31e4aa

4
app.js
View File

@ -19,6 +19,7 @@
// Defaults // Defaults
options.port = options.port || options.p || 8080; options.port = options.port || options.p || 8080;
options.directory = options.directory || options.D || '.';
['include', 'exclude', 'i', 'x'].forEach(function (opt) { ['include', 'exclude', 'i', 'x'].forEach(function (opt) {
options[opt] = options[opt] || []; options[opt] = options[opt] || [];
// Make sure includes/excludes always end up as arrays // Make sure includes/excludes always end up as arrays
@ -36,6 +37,7 @@
console.log(" --port, -p <number> Specify port."); console.log(" --port, -p <number> Specify port.");
console.log(" --include, -i <bundle> Include the specified bundle."); console.log(" --include, -i <bundle> Include the specified bundle.");
console.log(" --exclude, -x <bundle> Exclude the specified bundle."); console.log(" --exclude, -x <bundle> Exclude the specified bundle.");
console.log(" --directory, -D <bundle> Serve files from specified directory.");
console.log(""); console.log("");
process.exit(0); process.exit(0);
} }
@ -71,7 +73,7 @@
}); });
// Expose everything else as static files // Expose everything else as static files
app.use(express['static']('.')); app.use(express['static'](options.directory));
// Finally, open the HTTP server // Finally, open the HTTP server
app.listen(options.port); app.listen(options.port);