MCPcopy Create free account
hub / github.com/SethGammon/Citadel / runCommand

Function runCommand

scripts/operating-proof.js:72–93  ·  view source on GitHub ↗
(projectRoot, command)

Source from the content-addressed store, hash-verified

70}
71
72function runCommand(projectRoot, command) {
73 const parts = splitCommand(command);
74 if (parts.length === 0) return { status: 'skipped', exitCode: null, stdout: '', stderr: '' };
75
76 const isWindowsNpm = process.platform === 'win32' && parts[0] === 'npm';
77 const executable = isWindowsNpm ? 'cmd.exe' : parts[0];
78 const args = isWindowsNpm ? ['/d', '/s', '/c', 'npm', ...parts.slice(1)] : parts.slice(1);
79 const result = childProcess.spawnSync(executable, args, {
80 cwd: projectRoot,
81 encoding: 'utf8',
82 stdio: ['ignore', 'pipe', 'pipe'],
83 shell: false,
84 });
85
86 return {
87 status: result.status === 0 ? 'pass' : 'fail',
88 exitCode: result.status ?? 1,
89 stdout: result.stdout || '',
90 stderr: result.stderr || '',
91 error: result.error ? result.error.message : null,
92 };
93}
94
95function checkStatus(checks) {
96 if (checks.some((check) => check.status === 'fail')) return 'blocked';

Callers 1

checkVerifyFunction · 0.70

Calls 1

splitCommandFunction · 0.70

Tested by

no test coverage detected