Skip to content

Commit

Permalink
patch: do not fail if mtime null (e.g. in deno deploy)
Browse files Browse the repository at this point in the history
  • Loading branch information
dragonwocky committed May 18, 2022
1 parent bee72ed commit 4bb2b92
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,15 @@ const files: Map<string, [number, string]> = new Map(),
transformFile = async (path: string) => {
try {
const { mtime, isFile } = await Deno.stat(path);
if (!isFile || !mtime) return undefined;
if (files.has(path)) {
if (!isFile) return undefined;
if (mtime && files.has(path)) {
const [atime] = files.get(path)!,
expired = mtime.getTime() !== atime;
if (expired) files.delete(path);
}
if (!files.has(path)) {
const file = await Deno.readTextFile(path);
files.set(path, [mtime.getTime(), file]);
files.set(path, [mtime ? mtime.getTime() : 0, file]);
}
const lang = path.endsWith(".mjs") ? "js" : path.split(".").at(-1) ?? "",
[, file] = files.get(path)!;
Expand Down

0 comments on commit 4bb2b92

Please sign in to comment.