@epic-web/workshop-utils 6.23.3 → 6.23.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -15,7 +15,7 @@ async function getDirModifiedTime(dir, { forceFresh = false } = {}) {
|
|
|
15
15
|
return result;
|
|
16
16
|
}
|
|
17
17
|
async function getDirModifiedTimeImpl(dir) {
|
|
18
|
-
const isIgnored = await isGitIgnored({ cwd: dir });
|
|
18
|
+
const isIgnored = await isGitIgnored({ cwd: dir }).catch(() => () => false);
|
|
19
19
|
const files = await fs.promises
|
|
20
20
|
.readdir(dir, { withFileTypes: true })
|
|
21
21
|
.catch(() => []);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modified-time.server.js","sourceRoot":"","sources":["../../src/modified-time.server.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAA;AAEtB,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AACrC,OAAO,MAAM,MAAM,SAAS,CAAA;AAC5B,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAA;AAEnE,KAAK,UAAU,kBAAkB,CAChC,GAAW,EACX,EAAE,UAAU,GAAG,KAAK,KAA+B,EAAE;IAErD,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC;QAC9B,GAAG,EAAE,GAAG;QACR,KAAK,EAAE,oBAAoB;QAC3B,GAAG,EAAE,GAAG;QACR,UAAU;QACV,aAAa,EAAE,GAAG,EAAE,CAAC,sBAAsB,CAAC,GAAG,CAAC;KAChD,CAAC,CAAA;IACF,OAAO,MAAM,CAAA;AACd,CAAC;AAED,KAAK,UAAU,sBAAsB,CAAC,GAAW;IAChD,MAAM,SAAS,GAAG,MAAM,YAAY,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAA;
|
|
1
|
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AI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,kBAAkB,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CACvE,CAAA;IACD,MAAM,eAAe,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAA;IAClE,OAAO,eAAe,CAAA;AACvB,CAAC;AAED,IAAI,MAAM,GAAkB,IAAI,CAAA;AAChC,SAAS,QAAQ;IAChB,IAAI,MAAM;QAAE,OAAO,MAAM,CAAA;IAEzB,MAAM,GAAG,IAAI,MAAM,CAAC;QACnB,WAAW,EAAE,EAAE;QACf,cAAc,EAAE,IAAI;QACpB,OAAO,EAAE,IAAI,GAAG,EAAE;KAClB,CAAC,CAAA;IACF,OAAO,MAAM,CAAA;AACd,CAAC;AAED,+EAA+E;AAC/E,8EAA8E;AAC9E,KAAK,UAAU,wBAAwB,CACtC,GAAG,IAA2C;IAE9C,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAA;IACxB,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,kBAAkB,CAAC,GAAG,IAAI,CAAC,CAAC,CAAA;IACjE,OAAO,MAAM,IAAI,CAAC,CAAC,CAAA;AACpB,CAAC;AAED,OAAO,EAAE,wBAAwB,IAAI,kBAAkB,EAAE,CAAA","sourcesContent":["import './init-env.js'\n\nimport fs from 'node:fs'\nimport path from 'node:path'\nimport { isGitIgnored } from 'globby'\nimport PQueue from 'p-queue'\nimport { cachified, dirModifiedTimeCache } from './cache.server.js'\n\nasync function getDirModifiedTime(\n\tdir: string,\n\t{ forceFresh = false }: { forceFresh?: boolean } = {},\n): Promise<number> {\n\tconst result = await cachified({\n\t\tkey: dir,\n\t\tcache: dirModifiedTimeCache,\n\t\tttl: 200,\n\t\tforceFresh,\n\t\tgetFreshValue: () => getDirModifiedTimeImpl(dir),\n\t})\n\treturn result\n}\n\nasync function getDirModifiedTimeImpl(dir: string): Promise<number> {\n\tconst isIgnored = await isGitIgnored({ cwd: dir }).catch(() => () => false)\n\tconst files = await fs.promises\n\t\t.readdir(dir, { withFileTypes: true })\n\t\t.catch(() => [])\n\n\tconst modifiedTimes: Array<number> = []\n\n\tfor (const file of files) {\n\t\t// Skip ignored files\n\t\tif (isIgnored(file.name)) continue\n\n\t\tconst filePath = path.join(dir, file.name)\n\n\t\tif (file.isDirectory()) {\n\t\t\tmodifiedTimes.push(await getDirModifiedTime(filePath))\n\t\t} else {\n\t\t\ttry {\n\t\t\t\tconst { mtimeMs } = await fs.promises.stat(filePath)\n\t\t\t\tmodifiedTimes.push(mtimeMs)\n\t\t\t} catch {\n\t\t\t\t// ignore errors (e.g., file access permissions, file has been moved or deleted)\n\t\t\t}\n\t\t}\n\t}\n\n\ttry {\n\t\tconst { mtimeMs } = await fs.promises.stat(dir)\n\t\tmodifiedTimes.push(mtimeMs)\n\t} catch {\n\t\t// ignore errors (e.g., file access permissions, file has been moved or deleted)\n\t}\n\n\treturn Math.max(-1, ...modifiedTimes)\n}\n\n// this will return true as soon as one of the directories has been found to\n// have been modified more recently than the given time\n// TODO: this could be improved by not waiting for entire directories to be\n// scanned and instead stopping the scan as soon as we find a file that was\n// modified more recently than the given time\nexport async function modifiedMoreRecentlyThan(\n\ttime: number,\n\t...dirs: Array<string>\n) {\n\tconst modifiedTimePromises = dirs.map((dir) => getDirModifiedTime(dir))\n\tconst allFinishedPromise = Promise.all(modifiedTimePromises)\n\tconst firstMoreRecentPromise = modifiedTimePromises.map((p) =>\n\t\tp.then((t) => (t > time ? true : allFinishedPromise.then(() => false))),\n\t)\n\tconst firstMoreRecent = await Promise.race(firstMoreRecentPromise)\n\treturn firstMoreRecent\n}\n\nlet _queue: PQueue | null = null\nfunction getQueue() {\n\tif (_queue) return _queue\n\n\t_queue = new PQueue({\n\t\tconcurrency: 10,\n\t\tthrowOnTimeout: true,\n\t\ttimeout: 1000 * 60,\n\t})\n\treturn _queue\n}\n\n// We have to use a queue because we can't run more than one of these at a time\n// or we'll hit an out of memory error because esbuild uses a lot of memory...\nasync function queuedGetDirModifiedTime(\n\t...args: Parameters<typeof getDirModifiedTime>\n) {\n\tconst queue = getQueue()\n\tconst result = await queue.add(() => getDirModifiedTime(...args))\n\treturn result || -1\n}\n\nexport { queuedGetDirModifiedTime as getDirModifiedTime }\n"]}
|