Skip to content

Commit

Permalink
Merge pull request #31 from richardgoater/master
Browse files Browse the repository at this point in the history
Add "--open" Option
  • Loading branch information
tapio authored and bmuenzenmeyer committed Feb 23, 2018
1 parent c3597e5 commit 7dcf104
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/live-server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ LiveServer.start = function(options) {
console.log(('Serving "' + root + '" at ' + browserURL).green);

// Launch browser
if(!noBrowser)
open(browserURL);
if (!noBrowser)
open(browserURL + (options.open || ''));
};

module.exports = LiveServer;
16 changes: 13 additions & 3 deletions packages/live-server/live-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,29 @@ for (var i = process.argv.length-1; i >= 2; --i) {
opts.port = portNumber;
process.argv.splice(i, 1);
}
} else if (arg == "--no-browser") {
}
else if (arg.indexOf("--open=") > -1) {
var path = arg.substring(7);
if (path.indexOf('/') != 0) {
path = '/' + path;
}
opts.open = path;
process.argv.splice(i, 1);
}
else if (arg == "--no-browser") {
opts.noBrowser = true;
process.argv.splice(i, 1);
} else if (arg == "--quiet" || arg == "-q") {
opts.logLevel = 0;
process.argv.splice(i, 1);
} else if (arg == "--help" || arg == "-h") {
console.log('Usage: live-server [-h|--help] [--port=PORT] [--no-browser] [PATH]');
console.log('Usage: live-server [-h|--help] [-q|--quiet] [--port=PORT] [--open=PATH] [--no-browser] [PATH]');
process.exit();
}
}

if (process.argv[2])
if (process.argv[2]) {
process.chdir(process.argv[2]);
}

liveServer.start(opts);

0 comments on commit 7dcf104

Please # to comment.