Skip to content

Commit

Permalink
primitive browser env var with special none value supported
Browse files Browse the repository at this point in the history
  • Loading branch information
okwolf committed Mar 10, 2019
1 parent 3b977f5 commit 6a58ca4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,11 @@ srvs(options).then(config => {

The `options` object has the same properties and values as the arguments supported by the command line version. The `config` parameter provided to the resolved `Promise` has the same properties as `options`.

## Caveats
## Notes

- This is only for use as a development tool, please do not use in production.
- If you intend to use [dynamic import](https://github.com/tc39/proposal-dynamic-import#import) (as the `examples/hot` project does) to hot reload changed modules, be aware this is [not supported by some browsers](https://caniuse.com/#feat=es6-module-dynamic-import).
- The `BROWSER` environment variable can be used to control which application to open your page in, or set to `none` to disable browser opening entirely. This feature is inspired by the popular [`create-react-app`](https://facebook.github.io/create-react-app/docs/advanced-configuration).

## License

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "srvs",
"version": "0.3.2",
"version": "0.4.0",
"description": "Zero Dependency Dev Server",
"files": [
"src"
Expand Down
8 changes: 7 additions & 1 deletion src/client/openBrowser.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
const childProcess = require("child_process");

const { BROWSER } = process.env;

module.exports = url => {
let cmd;
const args = [];

if (process.platform === "darwin") {
if (BROWSER.toLowerCase() === "none") {
return false;
} else if (BROWSER) {
cmd = BROWSER;
} else if (process.platform === "darwin") {
try {
// Try our best to reuse existing tab
// on OS X Google Chrome with AppleScript
Expand Down

0 comments on commit 6a58ca4

Please sign in to comment.