diff options
author | Sebastian <sebasjm@gmail.com> | 2022-12-09 11:46:09 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2022-12-09 11:46:09 -0300 |
commit | f759c58a5900717ae4a322569ed5e64478462c9c (patch) | |
tree | 45accdd2612bb7bc96e71a1a94a5a3104bda3d3d /packages/web-util/src/serve.ts | |
parent | 24f6d8fc9a98108d1d74aeb96f57f39faa52f4fa (diff) | |
download | wallet-core-f759c58a5900717ae4a322569ed5e64478462c9c.tar.xz |
show error message when there is compilation error
Diffstat (limited to 'packages/web-util/src/serve.ts')
-rw-r--r-- | packages/web-util/src/serve.ts | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/packages/web-util/src/serve.ts b/packages/web-util/src/serve.ts index 736e57430..3248bbeb8 100644 --- a/packages/web-util/src/serve.ts +++ b/packages/web-util/src/serve.ts @@ -38,7 +38,6 @@ export async function serve(opts: { app.use(PATHS.APP, express.static(opts.folder)); const server = https.createServer(httpServerOptions, app); - server.listen(opts.port); logger.info(`serving ${opts.folder} on ${opts.port}`); logger.info(` ${PATHS.APP}: application`); logger.info(` ${PATHS.EXAMPLE}: examples`); @@ -74,21 +73,28 @@ export async function serve(opts: { logger.info(`watching ${watchingFolder} for change`); chokidar.watch(watchingFolder).on("change", (path, stats) => { - logger.trace(`changed ${path}`); + logger.info(`changed ${path}`); - sendToAllClients({ type: "file-updated-start", data: { path } }); if (opts.onUpdate) { + sendToAllClients({ type: "file-updated-start", data: { path } }); opts.onUpdate().then((result) => { sendToAllClients({ type: "file-updated-done", data: { path, result }, }); + }).catch((error) => { + sendToAllClients({ + type: "file-updated-failed", + data: { path, error }, + }); }); } else { - sendToAllClients({ type: "file-change-done", data: { path } }); + sendToAllClients({ type: "file-change", data: { path } }); } }); + if (opts.onUpdate) opts.onUpdate() + app.get(PATHS.EXAMPLE, function (req: any, res: any) { res.set("Content-Type", "text/html"); res.send( @@ -107,5 +113,7 @@ export async function serve(opts: { app.get(PATHS.NOTIFY, function (req: any, res: any) { res.send("ok"); }); + + server.listen(opts.port); } } |