Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit 06fd5d8

Browse files
committed
feat(fusuma): add open module
1 parent 29b65e5 commit 06fd5d8

File tree

5 files changed

+36
-0
lines changed

5 files changed

+36
-0
lines changed

packages/fusuma/package-lock.json

+22
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/fusuma/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"html-webpack-plugin": "^5.0.0-beta.6",
5050
"js-yaml": "^4.0.0",
5151
"mini-css-extract-plugin": "^1.3.5",
52+
"open": "^7.3.1",
5253
"optimize-css-assets-webpack-plugin": "^5.0.4",
5354
"ora": "^5.3.0",
5455
"postcss": "^8.2.4",

packages/fusuma/src/tasks/start.js

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const Spinner = require('../cli/Spinner');
44
const getRemoteOriginUrl = require('../utils/getRemoteOriginUrl');
55
const { start: webpackStart } = require('../webpack');
66
const { warn } = require('../cli/log');
7+
const openBrowser = require('../utils/openBrowser');
78

89
async function start(config) {
910
process.env.NODE_ENV = 'development';
@@ -25,6 +26,7 @@ async function start(config) {
2526
await webpackStart(config);
2627

2728
spinner.stop();
29+
await openBrowser(`http://localhost:${config.internal.port}`);
2830
}
2931

3032
module.exports = start;

packages/fusuma/src/tasks/startProd.js

+2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
const server = require('../server/fileServer');
44
const { info } = require('../cli/log');
5+
const openBrowser = require('../utils/openBrowser');
56

67
async function startProd(config) {
78
await server(config.internal.outputDirPath, config.build.publicPath, config.internal.port);
89
info('start-prod', `Serving on http://localhost:${config.internal.port}`);
10+
await openBrowser(`http://localhost:${config.internal.port}`);
911
}
1012

1113
module.exports = startProd;
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
'use stirct';
2+
3+
const open = require('open');
4+
5+
async function openBrowser(url) {
6+
await open(url);
7+
}
8+
9+
module.exports = openBrowser;

0 commit comments

Comments
 (0)