@techninja/clearstack 0.4.29 → 0.4.30

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.
Files changed (2) hide show
  1. package/lib/spec-utils.js +34 -5
  2. package/package.json +1 -1
package/lib/spec-utils.js CHANGED
@@ -4,7 +4,7 @@
4
4
  * @module lib/spec-utils
5
5
  */
6
6
 
7
- import { execSync } from 'node:child_process';
7
+ import { execSync, spawn } from 'node:child_process';
8
8
 
9
9
  /** @param {number} start */
10
10
  export function elapsed(start) {
@@ -69,16 +69,45 @@ export function runExtCmd(label, cmd, opts = {}) {
69
69
  /[/\\]node_modules[/\\]/,
70
70
  ...(opts.ignorePaths ?? []).map((p) => new RegExp(p.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'))),
71
71
  ];
72
+ const filter = (l) => l.trim() && !ignoreRe.some((re) => re.test(l)) && (!opts.lineFilter || opts.lineFilter(l));
73
+
74
+ // Streaming mode — used when onProgress is provided
75
+ if (opts.onProgress) {
76
+ return new Promise((resolve) => {
77
+ const [bin, ...args] = cmd.split(/\s+(?=(?:[^"]*"[^"]*")*[^"]*$)/);
78
+ const proc = spawn(bin, args, { cwd, shell: true });
79
+ const lines = [];
80
+ const onLine = (chunk) => {
81
+ for (const l of chunk.toString().split('\n')) {
82
+ if (!filter(l)) continue;
83
+ lines.push(l);
84
+ opts.onProgress(l);
85
+ }
86
+ };
87
+ proc.stdout.on('data', onLine);
88
+ proc.stderr.on('data', onLine);
89
+ proc.on('close', (code) => {
90
+ if (code === 0 || lines.length === 0) {
91
+ if (!opts.quiet) console.log(` ✅ ${label}${suffix()}`);
92
+ resolve({ pass: true, label, time: elapsed(start) });
93
+ } else {
94
+ if (!opts.quiet) {
95
+ console.log(` ❌ ${label}${suffix()}`);
96
+ for (const l of lines) console.log(` ${l}`);
97
+ }
98
+ resolve({ pass: false, label, time: elapsed(start), errors: lines });
99
+ }
100
+ });
101
+ });
102
+ }
103
+
72
104
  try {
73
105
  execSync(cmd, { cwd, stdio: 'pipe', encoding: 'utf-8' });
74
106
  if (!opts.quiet) console.log(` ✅ ${label}${suffix()}`);
75
107
  return { pass: true, label, time: elapsed(start) };
76
108
  } catch (err) {
77
109
  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
- .filter((l) => !opts.lineFilter || opts.lineFilter(l));
110
+ const errors = out.split('\n').filter(filter);
82
111
  if (errors.length === 0) {
83
112
  if (!opts.quiet) console.log(` ✅ ${label}${suffix()}`);
84
113
  return { pass: true, label, time: elapsed(start) };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@techninja/clearstack",
3
- "version": "0.4.29",
3
+ "version": "0.4.30",
4
4
  "type": "module",
5
5
  "description": "A no-build web component framework specification — scaffold, validate, and evolve spec-compliant projects",
6
6
  "bin": {