mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-12-04 06:21:59 +09:00
fix(windows): drop the remaining 2>/dev/null redirects in npm calls
Follow-up to #4770. `security cve`, `analyze deps --security` and the rvfa builder still ran npm with `2>/dev/null`, which fails under cmd.exe, so on Windows they never got any output. stderr is now captured through stdio instead. `analyze deps` also read nothing when npm audit exited non-zero (which it does whenever it finds vulnerabilities); it now reads the JSON from the error's stdout, the same way security.ts does.
This commit is contained in:
1 parent
dc25dd9b52
commit
327c5fc4ad
4 files changed
+25
-7
No files matched your search
@@ -5,10 +5,12 @@ import { join } from 'node:path';
|
||||
import { getGitUncommittedCount } from '../src/funnel/local-signals.js';
|
||||
|
||||
describe('#4770 no /dev/null redirects', () => {
|
||||
it('init does not redirect stderr to /dev/null', () => {
|
||||
const src = readFileSync(join(__dirname, '../src/commands/init.ts'), 'utf-8');
|
||||
expect(src).not.toMatch(/2>\s*\/dev\/null/);
|
||||
});
|
||||
for (const file of ['commands/init.ts', 'commands/analyze.ts', 'commands/security.ts', 'appliance/rvfa-builder.ts']) {
|
||||
it(`${file} does not redirect stderr to /dev/null`, () => {
|
||||
const src = readFileSync(join(__dirname, '../src', file), 'utf-8');
|
||||
expect(src).not.toMatch(/2>\s*\/dev\/null/);
|
||||
});
|
||||
}
|
||||
|
||||
it('getGitUncommittedCount returns a number in a git checkout', () => {
|
||||
// Was always undefined on Windows.
|
||||
|
||||
@@ -198,7 +198,11 @@ export class RvfaBuilder {
|
||||
private buildRufloSection(): Buffer {
|
||||
let packageMeta: Record<string, unknown> | null = null;
|
||||
try {
|
||||
const raw = execSync('npm pack ruflo@latest --dry-run --json 2>/dev/null', { encoding: 'utf-8', timeout: 15_000 });
|
||||
const raw = execSync('npm pack ruflo@latest --dry-run --json', {
|
||||
encoding: 'utf-8',
|
||||
timeout: 15_000,
|
||||
stdio: ['ignore', 'pipe', 'pipe'],
|
||||
});
|
||||
const parsed = JSON.parse(raw);
|
||||
if (Array.isArray(parsed) && parsed.length > 0) packageMeta = parsed[0];
|
||||
} catch { /* manifest-only fallback */ }
|
||||
|
||||
@@ -1495,7 +1495,19 @@ const depsCommand: Command = {
|
||||
output.writeln(output.dim('-'.repeat(60)));
|
||||
|
||||
try {
|
||||
const auditRaw = execSync('npm audit --json 2>/dev/null', { encoding: 'utf-8', maxBuffer: 10 * 1024 * 1024 });
|
||||
let auditRaw: string;
|
||||
try {
|
||||
auditRaw = execSync('npm audit --json', {
|
||||
encoding: 'utf-8',
|
||||
maxBuffer: 10 * 1024 * 1024,
|
||||
stdio: ['pipe', 'pipe', 'pipe'],
|
||||
});
|
||||
} catch (auditErr: unknown) {
|
||||
// npm audit exits non-zero when vulnerabilities found — stdout still has JSON
|
||||
const stdout = auditErr instanceof Error && 'stdout' in auditErr ? (auditErr as { stdout: string }).stdout : '';
|
||||
if (!stdout) throw auditErr;
|
||||
auditRaw = stdout;
|
||||
}
|
||||
const audit = JSON.parse(auditRaw);
|
||||
const vulns = audit.metadata?.vulnerabilities || audit.vulnerabilities || {};
|
||||
const info = vulns.info || 0;
|
||||
|
||||
@@ -505,7 +505,7 @@ const cveCommand: Command = {
|
||||
// If --check CVE-XXXX is given, filter to that specific CVE ID.
|
||||
let auditJson: string;
|
||||
try {
|
||||
auditJson = execSync('npm audit --json 2>/dev/null', {
|
||||
auditJson = execSync('npm audit --json', {
|
||||
encoding: 'utf-8',
|
||||
timeout: 30000,
|
||||
stdio: ['pipe', 'pipe', 'pipe'],
|
||||
|
||||
Reference in new issue
Block a user