@techninja/clearstack 0.4.25 → 0.4.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/check.js +1 -1
- package/lib/spec-utils.js +40 -0
- package/package.json +1 -1
package/lib/check.js
CHANGED
|
@@ -12,7 +12,7 @@ import { checkI18n } from './spec-i18n.js';
|
|
|
12
12
|
import { loadConfig, buildCmds, detectRunner } from './spec-config.js';
|
|
13
13
|
import { findTypeConfigs } from './spec-types.js';
|
|
14
14
|
|
|
15
|
-
export { runCmd, elapsed } from './spec-utils.js';
|
|
15
|
+
export { runCmd, runExtCmd, elapsed } from './spec-utils.js';
|
|
16
16
|
export { findFiles, countFiles, checkFileLines, checkImports } from './spec-scan.js';
|
|
17
17
|
export { checkI18n } from './spec-i18n.js';
|
|
18
18
|
export { loadConfig, buildCmds, detectRunner } from './spec-config.js';
|
package/lib/spec-utils.js
CHANGED
|
@@ -49,3 +49,43 @@ export function runCmd(label, cmd, cwd, stats, opts) {
|
|
|
49
49
|
return { pass: false, label, time: elapsed(start), errors: display };
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Run an arbitrary shell command for a custom extension check.
|
|
55
|
+
* Handles timing, output filtering, and consistent ✅/❌ printing.
|
|
56
|
+
* Ignores lines matching node_modules or any paths in `ignorePaths`.
|
|
57
|
+
* Use this in clearstack.spec.js extensions instead of execSync directly.
|
|
58
|
+
*
|
|
59
|
+
* @param {string} label - Display name for the check
|
|
60
|
+
* @param {string} cmd - Shell command to run
|
|
61
|
+
* @param {{ quiet?: boolean, cwd?: string, ignorePaths?: string[] }} [opts]
|
|
62
|
+
* @returns {CheckResult}
|
|
63
|
+
*/
|
|
64
|
+
export function runExtCmd(label, cmd, opts = {}) {
|
|
65
|
+
const start = performance.now();
|
|
66
|
+
const cwd = opts.cwd ?? process.cwd();
|
|
67
|
+
const suffix = () => ` (${elapsed(start)})`;
|
|
68
|
+
const ignoreRe = [
|
|
69
|
+
/[/\\]node_modules[/\\]/,
|
|
70
|
+
...(opts.ignorePaths ?? []).map((p) => new RegExp(p.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'))),
|
|
71
|
+
];
|
|
72
|
+
try {
|
|
73
|
+
execSync(cmd, { cwd, stdio: 'pipe', encoding: 'utf-8' });
|
|
74
|
+
if (!opts.quiet) console.log(` ✅ ${label}${suffix()}`);
|
|
75
|
+
return { pass: true, label, time: elapsed(start) };
|
|
76
|
+
} catch (err) {
|
|
77
|
+
const out = ((err.stdout || '') + (err.stderr || '')).trim();
|
|
78
|
+
const errors = out.split('\n')
|
|
79
|
+
.filter((l) => l.trim())
|
|
80
|
+
.filter((l) => !ignoreRe.some((re) => re.test(l)));
|
|
81
|
+
if (errors.length === 0) {
|
|
82
|
+
if (!opts.quiet) console.log(` ✅ ${label}${suffix()}`);
|
|
83
|
+
return { pass: true, label, time: elapsed(start) };
|
|
84
|
+
}
|
|
85
|
+
if (!opts.quiet) {
|
|
86
|
+
console.log(` ❌ ${label}${suffix()}`);
|
|
87
|
+
for (const line of errors) console.log(` ${line}`);
|
|
88
|
+
}
|
|
89
|
+
return { pass: false, label, time: elapsed(start), errors };
|
|
90
|
+
}
|
|
91
|
+
}
|
package/package.json
CHANGED