MCPcopy Create free account
hub / github.com/NativeScript/SimDeck / runBuffer

Function runBuffer

scripts/integration/cli.mjs:1804–1828  ·  view source on GitHub ↗
(command, args, options = {})

Source from the content-addressed store, hash-verified

1802}
1803
1804function runBuffer(command, args, options = {}) {
1805 const startedAt = Date.now();
1806 logCommand(command, args);
1807 const result = spawnSync(command, args, {
1808 cwd: root,
1809 encoding: "buffer",
1810 maxBuffer: options.maxBuffer ?? 16 * 1024 * 1024,
1811 env: options.env ? { ...process.env, ...options.env } : process.env,
1812 timeout: options.timeoutMs ?? 120_000,
1813 });
1814 if (result.status !== 0) {
1815 throw new Error(
1816 `${command} ${args.join(" ")} failed with ${result.status ?? result.signal}\n${result.stderr?.toString("utf8") ?? ""}\n${result.error?.message ?? ""}`,
1817 );
1818 }
1819 const elapsedMs = Date.now() - startedAt;
1820 recordCommandTiming(command, args, elapsedMs);
1821 if (options.maxElapsedMs && elapsedMs > options.maxElapsedMs) {
1822 throw new Error(
1823 `${command} ${args.join(" ")} took ${elapsedMs}ms, above ${options.maxElapsedMs}ms budget`,
1824 );
1825 }
1826 logCommandResult(command, args, elapsedMs, `<${result.stdout.length} bytes>`);
1827 return result.stdout;
1828}
1829
1830function recordCommandTiming(command, args, elapsedMs) {
1831 if (!activeTiming) {

Callers 1

mainFunction · 0.70

Calls 4

logCommandFunction · 0.85
recordCommandTimingFunction · 0.85
logCommandResultFunction · 0.85
toStringMethod · 0.80

Tested by

no test coverage detected