Download scripts/ensure-test-bundle-fresh.mjs from xjackkx/s2: direct link, hf CLI and curl.
- Browser
- Download file 721 Bytes
-
https://huggingface.co/spaces/xjackkx/s2/resolve/main/scripts/ensure-test-bundle-fresh.mjs
- Command line
-
hf download hf://spaces/xjackkx/s2/scripts/ensure-test-bundle-fresh.mjs
-
curl -L -o ensure-test-bundle-fresh.mjs https://huggingface.co/spaces/xjackkx/s2/resolve/main/scripts/ensure-test-bundle-fresh.mjs
721 Bytes
| import { existsSync, globSync, statSync } from "node:fs"; | |
| import { runCommand } from "./process.mjs"; | |
| const bundlePaths = ["dist/worker.test.js", "dist/worker.js"]; | |
| const sourceGlobs = [ | |
| "src/**/*.ts", | |
| "scripts/build.mjs", | |
| "package.json", | |
| "tsconfig.json", | |
| ]; | |
| if (needsBuild()) { | |
| await runCommand(process.execPath, ["scripts/build.mjs", "--test-bundle"]); | |
| } | |
| function needsBuild() { | |
| if (bundlePaths.some((path) => !existsSync(path))) return true; | |
| const oldestBundleMtime = Math.min( | |
| ...bundlePaths.map((path) => statSync(path).mtimeMs), | |
| ); | |
| for (const pattern of sourceGlobs) { | |
| for (const path of globSync(pattern)) { | |
| if (statSync(path).mtimeMs > oldestBundleMtime) return true; | |
| } | |
| } | |
| return false; | |
| } | |