Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5223d28

Browse files
M-ZubairAhmedvinaypuppal
M-ZubairAhmed
authored andcommitted
auto start of browser on yarn run dev
1 parent 7b40060 commit 5223d28

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
"normalize-url": "1.9.1",
9393
"now": "8.3.10",
9494
"octonode": "0.9.1",
95+
"opn": "^5.1.0",
9596
"prettier": "^1.7.0",
9697
"travis-after-all": "1.4.5",
9798
"url-regex": "4.1.1",

server.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const { createServer } = require('http');
22
const { parse } = require('url');
33
const next = require('next');
44
const pathMatch = require('path-match');
5+
const opn = require('opn');
56

67
const port = parseInt(process.env.PORT, 10) || 3000;
78
const dev = process.env.NODE_ENV !== 'production';
@@ -24,6 +25,7 @@ app.prepare().then(() => {
2425
app.render(req, res, '/learn/subject', Object.assign(params, query));
2526
}).listen(port, err => {
2627
if (err) throw err;
27-
console.log(`> Ready on http://localhost:${port}`);
28+
console.log(`>> App running on http://localhost:${port}`);
29+
opn(`http://localhost:${port}`);
2830
});
2931
});

yarn.lock

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3424,6 +3424,10 @@ is-windows@^1.0.0:
34243424
version "1.0.1"
34253425
resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.1.tgz#310db70f742d259a16a369202b51af84233310d9"
34263426

3427+
is-wsl@^1.1.0:
3428+
version "1.1.0"
3429+
resolved "https://registry.yarnpkg.com/is-wsl/-/is-wsl-1.1.0.tgz#1f16e4aa22b04d1336b66188a66af3c600c3a66d"
3430+
34273431
34283432
version "0.0.1"
34293433
resolved "https://registry.yarnpkg.com/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf"
@@ -4729,6 +4733,12 @@ opener@^1.4.3:
47294733
version "1.4.3"
47304734
resolved "https://registry.yarnpkg.com/opener/-/opener-1.4.3.tgz#5c6da2c5d7e5831e8ffa3964950f8d6674ac90b8"
47314735

4736+
opn@^5.1.0:
4737+
version "5.1.0"
4738+
resolved "https://registry.yarnpkg.com/opn/-/opn-5.1.0.tgz#72ce2306a17dbea58ff1041853352b4a8fc77519"
4739+
dependencies:
4740+
is-wsl "^1.1.0"
4741+
47324742
optimist@^0.6.1:
47334743
version "0.6.1"
47344744
resolved "https://registry.yarnpkg.com/optimist/-/optimist-0.6.1.tgz#da3ea74686fa21a19a111c326e90eb15a0196686"

0 commit comments

Comments
 (0)