browse-url

1.1.5 • Public • Published

browse-url: Open URLs in a browser.

npm-version npm-week-downloads

Open URLs in a browser. Easy to use and test your project.

Installing

npm install --save-dev browse-url

Usage example

var http = require("http");
var port = process.env.PORT || 1337;

http.createServer(function (req, res) {
    res.writeHead(200, { "Content-Type": "text/plain" });
    res.end("Hello World\n");
}).listen(port);

var url = "http://localhost:" + port + "/";

/* longer version */
var browseURL = require("./index.min.js");
var childProcess = browseURL(url);
if (childProcess) {
    childProcess.on("exit", function (code) {
        setTimeout(function () { process.exit(); }, 5000);
    });
}

/* short version */
//require("browse-url");
//require("browse-url")(url);

Config-sets file

config-sets.json Read more...

{
  "production": {
    "isDebug": false,
    "browse_url": {
      "launch_url": "http://example.com/",
      "enabled": false
    }
  },
  "development": {
    "isDebug": true,
    "browse_url": {
      "launch_url": "http://localhost:1337/",
      "enabled": true
    }
  }
}

License

MIT

Copyright (c) 2021 Manuel Lõhmus manuel@hauss.ee

Package Sidebar

Install

npm i browse-url

Weekly Downloads

14

Version

1.1.5

License

MIT

Unpacked Size

9.31 kB

Total Files

9

Last publish

Collaborators

  • manupro