MCPcopy Create free account
hub / github.com/heygen-com/hyperframes / directorySizeBytes

Function directorySizeBytes

packages/aws-lambda/scripts/build-zip.ts:511–523  ·  view source on GitHub ↗
(dir: string)

Source from the content-addressed store, hash-verified

509}
510
511function directorySizeBytes(dir: string): number {
512 // Use spawnSync (no shell) instead of execSync so `dir` is passed as
513 // an argv element rather than interpolated into a shell command —
514 // CodeQL's `js/shell-command-injected-from-environment` rule fires
515 // on the latter even with JSON-quoting. `du -sb` is Linux-only;
516 // build-zip is CI-side where Linux coreutils is present.
517 const result = spawnSync("du", ["-sb", dir], { encoding: "utf-8" });
518 if (result.status === 0 && result.stdout) {
519 const bytes = Number.parseInt(result.stdout.split(/\s+/)[0] ?? "0", 10);
520 if (!Number.isNaN(bytes)) return bytes;
521 }
522 return walkSize(dir);
523}
524
525function walkSize(dir: string): number {
526 let total = 0;

Callers 1

mainFunction · 0.85

Calls 1

walkSizeFunction · 0.85

Tested by

no test coverage detected