readBuildFile
uses node:fs
Read a file of a build in place: one being replaced (--force, another tcm's) is moved aside an instant before the
new one is put there (publishBuild), so a file missing is looked for again, for a moment, before that's an
error.
import fs from "node:fs"; export function readBuildFile(file: string): Buffer { for (let tries = 0; ; tries++) { try { return fs.readFileSync(file); } catch (e) { if ((e as NodeJS.ErrnoException).code !== "ENOENT" || tries >= 20) throw e; Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 5); } } }