Skip to content

Commit 4bb2b92

Browse files
committed
patch: do not fail if mtime null (e.g. in deno deploy)
1 parent bee72ed commit 4bb2b92

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

transform.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,15 +175,15 @@ const files: Map<string, [number, string]> = new Map(),
175175
transformFile = async (path: string) => {
176176
try {
177177
const { mtime, isFile } = await Deno.stat(path);
178-
if (!isFile || !mtime) return undefined;
179-
if (files.has(path)) {
178+
if (!isFile) return undefined;
179+
if (mtime && files.has(path)) {
180180
const [atime] = files.get(path)!,
181181
expired = mtime.getTime() !== atime;
182182
if (expired) files.delete(path);
183183
}
184184
if (!files.has(path)) {
185185
const file = await Deno.readTextFile(path);
186-
files.set(path, [mtime.getTime(), file]);
186+
files.set(path, [mtime ? mtime.getTime() : 0, file]);
187187
}
188188
const lang = path.endsWith(".mjs") ? "js" : path.split(".").at(-1) ?? "",
189189
[, file] = files.get(path)!;

0 commit comments

Comments
 (0)