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

Function run

hooks_src/quality-gate.js:109–187  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

107}
108
109function run() {
110 health.increment('quality-gate', 'count');
111
112 const projectDir = health.PROJECT_ROOT;
113 const config = health.readConfig();
114
115 // Get recently modified files from git
116 let changedFiles = [];
117 try {
118 let output;
119 try {
120 output = execFileSync('git', ['diff', '--name-only', 'HEAD'], {
121 cwd: projectDir,
122 encoding: 'utf8',
123 timeout: 5000,
124 stdio: ['pipe', 'pipe', 'pipe'],
125 });
126 } catch {
127 // HEAD may not exist (fresh repo) — fall back to plain diff
128 output = execFileSync('git', ['diff', '--name-only'], {
129 cwd: projectDir,
130 encoding: 'utf8',
131 timeout: 5000,
132 stdio: ['pipe', 'pipe', 'pipe'],
133 });
134 }
135 changedFiles = output.trim().split('\n').filter(Boolean);
136 } catch {
137 process.exit(0);
138 }
139
140 if (changedFiles.length === 0) {
141 process.exit(0);
142 }
143
144 const violations = [];
145 const builtInRules = config.qualityRules?.builtIn || ['no-confirm-alert', 'no-transition-all'];
146
147 for (const file of changedFiles) {
148 const fullPath = path.join(projectDir, file);
149 if (!fs.existsSync(fullPath)) continue;
150 if (!/\.(ts|tsx|js|jsx|py|go|rs|css|scss|md)$/.test(file)) continue;
151
152 let content;
153 try {
154 content = fs.readFileSync(fullPath, 'utf8');
155 } catch {
156 continue;
157 }
158
159 const lenses = selectColdPathLenses(file);
160
161 for (const lens of lenses) {
162 const lensViolations = runColdLens(lens, file, content, config, builtInRules);
163 violations.push(...lensViolations);
164 }
165 }
166

Callers 1

quality-gate.jsFile · 0.70

Calls 3

selectColdPathLensesFunction · 0.85
runColdLensFunction · 0.85
hookOutputFunction · 0.70

Tested by

no test coverage detected