Bug Description
gbrain put <slug> fails on Windows with ENOENT: /dev/stdin error.
Steps to Reproduce
- On Windows, run:
echo "some content" | gbrain put test-slug
- Observe error
Expected Behavior
gbrain put should read stdin content and create/update the page successfully on all platforms.
Actual Behavior
Error: ENOENT: no such file or directory, open '/dev/stdin'
Root Cause
In src/cli.ts, stdin is read via:
const stdinContent = readFileSync('/dev/stdin', 'utf-8');
/dev/stdin does not exist on Windows. This path is Unix-only.
Proposed Fix
Wrap the stdin read in a try/catch with a Windows fallback using readSync on fd 0:
// In src/cli.ts, replace:
const stdinContent = readFileSync('/dev/stdin', 'utf-8');
// With:
let stdinContent: string;
try {
stdinContent = readFileSync('/dev/stdin', 'utf-8');
} catch {
// Windows fallback: read from stdin fd directly
const fd = 0;
const chunks: Buffer[] = [];
const buf = Buffer.alloc(65536);
let nread: number;
while ((nread = readSync(fd, buf, 0, buf.length, null)) > 0) {
chunks.push(buf.slice(0, nread));
}
stdinContent = Buffer.concat(chunks).toString('utf-8');
}
Also need to add readSync to the import:
import { readFileSync, readSync } from 'fs';
Environment
- OS: Windows 11
- gbrain version: 0.39.0
- Runtime: Bun
Additional Context
This affects all gbrain put operations that pipe content via stdin on Windows. The --file parameter workaround (using a temp file) works, but stdin piping is a common UX pattern that should work cross-platform.
Bug Description
gbrain put <slug>fails on Windows withENOENT: /dev/stdinerror.Steps to Reproduce
echo "some content" | gbrain put test-slugExpected Behavior
gbrain putshould read stdin content and create/update the page successfully on all platforms.Actual Behavior
Root Cause
In
src/cli.ts, stdin is read via:/dev/stdindoes not exist on Windows. This path is Unix-only.Proposed Fix
Wrap the stdin read in a try/catch with a Windows fallback using
readSyncon fd 0:Also need to add
readSyncto the import:Environment
Additional Context
This affects all
gbrain putoperations that pipe content via stdin on Windows. The--fileparameter workaround (using a temp file) works, but stdin piping is a common UX pattern that should work cross-platform.