From 32e36f1c160cb120030887d833d37aea994103a5 Mon Sep 17 00:00:00 2001 From: "Jose Danilo Sampaio da Silva (Venturus)" Date: Mon, 31 Aug 2020 16:57:41 -0300 Subject: [PATCH] Fix #158 handle properly dependencies cache when deno/deps does not exists It handles ENOENT error thrown by the getAllDenoCachedDeps function when the deno/deps directory does not exists (e.g. a deno fresh install). Fix #158 --- core/deno_deps.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/core/deno_deps.ts b/core/deno_deps.ts index 06281c40..bd3905e7 100644 --- a/core/deno_deps.ts +++ b/core/deno_deps.ts @@ -31,7 +31,16 @@ export type Range = { export async function getAllDenoCachedDeps(): Promise { const depsRootDir = getDenoDepsDir(); const deps: Deps[] = []; - const protocols = await fs.readdir(depsRootDir); + let protocols: string[] = []; + + try { + protocols = await fs.readdir(depsRootDir); + } catch (error) { + //deno/deps directory does not exists + if (error.code === "ENOENT") { + return deps; + } + } await Promise.all( protocols.map(async (protocol) => {