Skip to content

Commit

Permalink
Add support for custom port (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
pacocoursey committed Oct 5, 2020
1 parent f0fd540 commit a557f10
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
7 changes: 6 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ if (cmd === "help" || args.some((a) => a === "-h" || a === "--help")) {
}

const isDev = cmd === "dev";
const port = 5000;
const portOptionIndex = args.findIndex((a) => a === "-p" || a === "--port")
let port = 5000
if (~portOptionIndex && args[portOptionIndex + 1]) {
port = args[portOptionIndex + 1];
args.splice(portOptionIndex, 2);
}

const rootDir = args.reduce((rootDir, option, index) => {
if (["-r", "--root"].includes(option) && args[index + 1]) {
Expand Down
8 changes: 7 additions & 1 deletion utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,13 @@ module.exports.help = function help() {
}
);
log(
` <b>--htmlOnly</b> Compiles and copies only the built HTML files\n`,
` <b>--htmlOnly</b> Compiles and copies only the built HTML files`,
{
prefix: false,
}
);
log(
` <b>--port</b> Port used for the dev server (default: 5000)\n`,
{
prefix: false,
}
Expand Down

0 comments on commit a557f10

Please sign in to comment.