Skip to content
This repository has been archived by the owner on Oct 6, 2021. It is now read-only.

Commit

Permalink
Added --open flag to maji cli
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanPahlplatz committed Sep 18, 2018
1 parent 98cc814 commit f78c08b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@
"commander": "~2.9.0",
"cross-spawn": "^5.1.0",
"git-revision-webpack-plugin": "^2.5.1",
"i18n-js": "http://github.com/fnando/i18n-js/archive/v3.0.0.rc8.tar.gz"
"i18n-js": "http://github.com/fnando/i18n-js/archive/v3.0.0.rc8.tar.gz",
"opn": "^5.3.0"
},
"engines": {
"node": ">=8"
Expand Down
6 changes: 6 additions & 0 deletions src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const { runYarn, runCordova } = require("./utils");
const parseBoolean = value => value === "true";
const parsePort = value => parseInt(value) || null;

const opn = require("opn");
const program = require("commander");
program.version(maji_package.version);

Expand Down Expand Up @@ -95,12 +96,17 @@ program
parseBoolean,
true
)
.option("-o --open", "Open the browser")
.action(options => {
const env = {
SERVER_PORT: options.port,
LIVERELOAD: options.livereload
};

if (options.open) {
opn(`http://localhost:${options.port}`);
}

return runYarn(["start"], env);
});

Expand Down
10 changes: 10 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2347,6 +2347,10 @@ is-windows@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.2.tgz#d1850eb9791ecd18e6182ce12a30f396634bb19d"

is-wsl@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/is-wsl/-/is-wsl-1.1.0.tgz#1f16e4aa22b04d1336b66188a66af3c600c3a66d"

isarray@0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf"
Expand Down Expand Up @@ -3189,6 +3193,12 @@ onetime@^2.0.0:
dependencies:
mimic-fn "^1.0.0"

opn@^5.3.0:
version "5.3.0"
resolved "https://registry.yarnpkg.com/opn/-/opn-5.3.0.tgz#64871565c863875f052cfdf53d3e3cb5adb53b1c"
dependencies:
is-wsl "^1.1.0"

optimist@^0.6.1:
version "0.6.1"
resolved "https://registry.yarnpkg.com/optimist/-/optimist-0.6.1.tgz#da3ea74686fa21a19a111c326e90eb15a0196686"
Expand Down

0 comments on commit f78c08b

Please sign in to comment.