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 11import { config } from "../lib/config" ;
22import { getFileSystemRepo } from "../lib/get-file-system-repo" ;
33import { getQiitaApiInstance } from "../lib/get-qiita-api-instance" ;
4+ import { getUrlAddress } from "../lib/getUrlAddress" ;
45import { syncArticlesFromQiita } from "../lib/sync-articles-from-qiita" ;
56import { startLocalChangeWatcher , startServer } from "../server/app" ;
67
@@ -13,9 +14,11 @@ export const preview = async () => {
1314 const server = await startServer ( ) ;
1415
1516 const address = server . address ( ) ;
16- if ( address && typeof address !== "string" ) {
17+ const url = getUrlAddress ( address ) ;
18+
19+ if ( url ) {
1720 const open = ( await import ( "open" ) ) . default ;
18- await open ( `http://localhost: ${ address . port } ` ) ;
21+ await open ( url ) ;
1922 }
2023
2124 startLocalChangeWatcher ( {
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import { EmojiRouter } from "./api/emoji";
1010import { ItemsRouter } from "./api/items" ;
1111import { ReadmeRouter } from "./api/readme" ;
1212import { config } from "../lib/config" ;
13+ import { getUrlAddress } from "../lib/getUrlAddress" ;
1314
1415export async function startServer ( ) {
1516 const app = express ( ) ;
@@ -39,7 +40,11 @@ export async function startServer() {
3940 server
4041 . listen ( port , host )
4142 . 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+ }
4348
4449 resolve ( server ) ;
4550 } )
You can’t perform that action at this time.
0 commit comments