From eca0888f38715afc68c20c3b1afab520f0e03ea9 Mon Sep 17 00:00:00 2001 From: X Date: Thu, 4 Feb 2021 22:50:06 +0800 Subject: [PATCH] fix: remove `deno cache` (#118) --- server/app.ts | 20 ++++---------------- server/server.ts | 2 +- 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/server/app.ts b/server/app.ts index 4661a55c8..824b87938 100644 --- a/server/app.ts +++ b/server/app.ts @@ -1256,29 +1256,17 @@ export class Application { return await Deno.readFile(cacheFilename) } - try { - const p = Deno.run({ - cmd: [Deno.execPath(), 'cache', reload ? '--reload' : '', u.toString()], - stdout: 'inherit', - stderr: 'piped' - }) - await Deno.stderr.write(await p.stderrOutput()) - await p.status() - p.close() - if (existsFileSync(cacheFilename)) { - return await Deno.readFile(cacheFilename) - } - } catch (e) { } - // download dep when deno cache failed - console.log(colors.green('Force download'), url) + log.info('Download', url) const buffer = await fetch(u.toString()).then(resp => { if (resp.status !== 200) { return Promise.reject(new Error(resp.statusText)) } return resp.arrayBuffer() }) - return await Deno.readAll(new Deno.Buffer(buffer)) + const content = await Deno.readAll(new Deno.Buffer(buffer)) + await Deno.writeFile(cacheFilename, content) + return content } /** bundle modules for production. */ diff --git a/server/server.ts b/server/server.ts index 89d723427..958e77f5f 100644 --- a/server/server.ts +++ b/server/server.ts @@ -166,7 +166,7 @@ export async function serve(hostname: string, port: number, app: Application) { } } catch (err) { if (err instanceof Deno.errors.AddrInUse) { - log.warn(`port ${port} already in use, try ${port + 1}`) + log.warn(`port ${port} already in use, try ${port + 1}...`) port++ } else { log.fatal(err.message)