Skip to content

Commit

Permalink
open the browser after server start
Browse files Browse the repository at this point in the history
  • Loading branch information
saharj committed Apr 6, 2016
1 parent e2fb20c commit 3a45148
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 27 deletions.
37 changes: 12 additions & 25 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,41 +8,28 @@ You can set the environment variable `PORT` to set the port
PORT=81 npm start
```

### Disallowing the browser to open

### Installing dependencies
This app have npm dependencies. To install all dependencies in one line, run
```shell
npm install;
```
Set `DO_NOT_OPEN` environment variable to start the server without
opening the browser

### Running in development mode
Simply run
```shell
grunt serve
DO_NOT_OPEN=true npm start
```
if you don't have `grunt` installed, you can run `npm run develop` instead.

You can also specify the port by setting `PORT` environment variable in development mode

```shell
PORT=3000 grunt serve
```

or

### Installing dependencies
This app have npm dependencies. To install all dependencies in one line, run
```shell
PORT=3000 npm run develop
npm install;
```

For development it's preferred to have `grunt` installed globally on your machine.

### Building
To build the project just run:

```shell
grunt build
npm run build
```
This will build a new version of the web app, ready for production in `/dist` folder
This will build a new version of the web app, ready for production

### Configuration
Swagger Editor will make an XHR GET call to `/config/defaults.json` to get it's settings before launch. If you are using Swagger Editor as a dependency or serving it statically, you can provide your own `defaults.json` at this endpoint to override default settings.
Expand Down Expand Up @@ -85,12 +72,12 @@ This will build and run unit tests then if it was successful, it will run end-t
All unit tests are located in [`../test/unit`](../test/unit). Unit tests are written in Jasmine and run by Karma. To run unit tests, run

```shell
grunt karma:unit
npm run unit-test
```

For developing unit tests, run
```shell
grunt test-dev
npm run unit-test-watch
```
This will keep test browser and test watcher open and watches for file changes to re-run tests.

Expand All @@ -99,5 +86,5 @@ All end-to-end tests are located in [`../test/e2e`](../test/e2e). To run end-to-

```shell
grunt protr
```
npm run e2e-test
This will run [Protractor](http://angular.github.io/protractor/#/) end-to-end test.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"ng-annotate-webpack-plugin": "^0.1.2",
"ng-file-upload": "^12.0.4",
"ngstorage": "^0.3.10",
"open": "0.0.5",
"open-sans-fontface": "^1.4.0",
"protractor": "^3.2.1",
"sinon": "^1.17.3",
Expand Down
13 changes: 11 additions & 2 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
var webpack = require('webpack');
var WebpackDevServer = require('webpack-dev-server');
var config = require('./webpack.config');
var argv = require('minimist')(process.argv.slice(2));
var open = require('open');
var IP = '127.0.0.1';

/*
Expand Down Expand Up @@ -33,9 +35,16 @@ if (process.argv[1] === __filename) {
return console.log(err);
}

// TODO: open browser in development mode
var url = 'http://' + IP + ':' + PORT;

console.log('Development server started at http://' + IP + ':' + PORT);
console.log('Development server started at', url);

// to avoid opening the browser set DO_NOT_OPEN environment
// variable to ture
if (!process.env.DO_NOT_OPEN) {
console.log('Opening the browser');
open(url);
}
});
}

Expand Down

0 comments on commit 3a45148

Please sign in to comment.