INNER CODE UNIT · TypeScript
deadline
NVIDIA/NemoClaw · .dsh/tools/check_changed_files_for_nul_bytes/index.ts:28
const deadline = Date.now() + 30000;
for (const file of changed.files) {
const remainingMs = deadline - Date.now();
if (remainingMs <= 0) throw new Error("Could not scan changed files");
const result = await tools.bash({
command:
"set -o pipefail; if [ ! -f " +
quote(file) +
" ]; then exit 3; fi; LC_ALL=C od -An -v -t u1 -- " +
quote(file) +
" | awk '{ for (i = 1; i <= NF; i++) if ($i == 0) count++ } END { print count + 0 }'",
workdir: input.workdir,
description: "Count NUL bytes in changed file",
timeoutMs: remainingMs,
});
if (result.kind !== "foreground") throw new Error("Could not scan changed files");
if (result.exitCode === 3) continue;
if (result.exitCode !== 0) throw new Error("Could not scan changed files");