Skip to content

Commit

Permalink
Added tests & updated deps
Browse files Browse the repository at this point in the history
  • Loading branch information
Grynn committed Jun 15, 2022
1 parent 2c5dfde commit 75176fe
Show file tree
Hide file tree
Showing 3 changed files with 9,357 additions and 3,616 deletions.
19 changes: 15 additions & 4 deletions bin/open.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const openBrowser = require("react-dev-utils/openBrowser");
const chalk = require("chalk");
const argv = require("minimist")(process.argv.slice(2));
const argv = require("minimist")(process.argv.slice(2), { boolean: [ 'n', 'dry-run' ], alias: { 'n': 'dry-run' }});

let uri;

Expand All @@ -12,6 +12,12 @@ if (argv["?"] || argv.h || argv.help) {
return 0;
}

if (argv._.length == 0) {
error_log("No URL specified");
usage();
return 1;
}

let arg = argv._.join();
if (!arg.match(/^https?:\/\//)) {
arg = "http://" + arg;
Expand All @@ -26,13 +32,18 @@ try {
return 1;
}

//Is dry run?
if (argv.n) {
process.env.BROWSER = "none";
}

//Let's open...
let opened = openBrowser(uri);
if (!opened) {
error_log(`Could not open: ${uri}"`);
if (!opened && !argv.n) {
error_log(`Could not open: "${uri}"`);
return 1;
} else {
console.log(chalk.blue(`Launched: ${uri}`));
console.log(chalk.blue(`${argv.n ? "Dry-run": "Launched"}: ${uri}`));
}

return 0;
Expand Down
Loading

0 comments on commit 75176fe

Please sign in to comment.