Skip to content

Commit

Permalink
Fix denoland#158 handle properly dependencies cache when deno/deps do…
Browse files Browse the repository at this point in the history
…es 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 denoland#158
  • Loading branch information
Jose Danilo Sampaio da Silva (Venturus) committed Aug 31, 2020
1 parent 8447851 commit 32e36f1
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion core/deno_deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,16 @@ export type Range = {
export async function getAllDenoCachedDeps(): Promise<Deps[]> {
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) => {
Expand Down

0 comments on commit 32e36f1

Please sign in to comment.