File tree Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change 1
1
import { config } from "../lib/config" ;
2
2
import { getFileSystemRepo } from "../lib/get-file-system-repo" ;
3
3
import { getQiitaApiInstance } from "../lib/get-qiita-api-instance" ;
4
+ import { getUrlAddress } from "../lib/getUrlAddress" ;
4
5
import { syncArticlesFromQiita } from "../lib/sync-articles-from-qiita" ;
5
6
import { startLocalChangeWatcher , startServer } from "../server/app" ;
6
7
@@ -13,9 +14,11 @@ export const preview = async () => {
13
14
const server = await startServer ( ) ;
14
15
15
16
const address = server . address ( ) ;
16
- if ( address && typeof address !== "string" ) {
17
+ const url = getUrlAddress ( address ) ;
18
+
19
+ if ( url ) {
17
20
const open = ( await import ( "open" ) ) . default ;
18
- await open ( `http://localhost: ${ address . port } ` ) ;
21
+ await open ( url ) ;
19
22
}
20
23
21
24
startLocalChangeWatcher ( {
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import { EmojiRouter } from "./api/emoji";
10
10
import { ItemsRouter } from "./api/items" ;
11
11
import { ReadmeRouter } from "./api/readme" ;
12
12
import { config } from "../lib/config" ;
13
+ import { getUrlAddress } from "../lib/getUrlAddress" ;
13
14
14
15
export async function startServer ( ) {
15
16
const app = express ( ) ;
@@ -39,7 +40,11 @@ export async function startServer() {
39
40
server
40
41
. listen ( port , host )
41
42
. once ( "listening" , ( ) => {
42
- console . log ( `Preview: http://${ host } :${ port } ` ) ;
43
+ const address = server . address ( ) ;
44
+ const url = getUrlAddress ( address ) ;
45
+ if ( url ) {
46
+ console . log ( `Preview: ${ url } ` )
47
+ }
43
48
44
49
resolve ( server ) ;
45
50
} )
You can’t perform that action at this time.
0 commit comments