Skip to content

Commit

Permalink
fix: remove deno cache (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
ije committed Feb 4, 2021
1 parent 06048eb commit eca0888
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 17 deletions.
20 changes: 4 additions & 16 deletions server/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down
2 changes: 1 addition & 1 deletion server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit eca0888

Please sign in to comment.