storebound 0.8.3: prompts read stdin with rt.readLine (node:readline) instead of Bun-only for await (const line of console), which crashed npx storebound desktop on Node/Windows; node-compat test bans Bun-only stdin iteration; Node prompt smoke, also on the Windows release runner
This commit is contained in:
parent
c3fed8efa2
commit
3a27c78f49
8 changed files with 111 additions and 9 deletions
|
|
@ -29,6 +29,19 @@ describe('cli/ is runtime neutral', () => {
|
|||
expect(bad).toEqual([]);
|
||||
});
|
||||
|
||||
test('no Bun-only runtime behaviour: console as a stdin iterator, prompt(), alert(), HTMLRewriter (use rt.readLine)', () => {
|
||||
// `for await (const line of console)` works only on Bun; on Node (npx storebound) it throws
|
||||
// "console is not async iterable" at the first prompt (owner's report on Windows, 0.8.2).
|
||||
const bad: string[] = [];
|
||||
for (const f of cliSources()) {
|
||||
const rel = relative(ROOT, f);
|
||||
readFileSync(f, 'utf8').split('\n').forEach((line, i) => {
|
||||
if (/\bof\s+console\b|console\s*\[\s*Symbol\.asyncIterator|(^|[;{(=\s])(globalThis\.)?(prompt|alert)\s*\(\s*['"`]|\bnew\s+HTMLRewriter\b/.test(line.replace(/\/\/.*$/, ''))) bad.push(`${rel}:${i + 1}: ${line.trim().slice(0, 120)}`);
|
||||
});
|
||||
}
|
||||
expect(bad).toEqual([]);
|
||||
});
|
||||
|
||||
test('package.json: bin is the Node bundle, engines name Node 20, npm pack builds it', () => {
|
||||
const pkg = JSON.parse(readFileSync(join(ROOT, 'package.json'), 'utf8')) as { bin: Record<string, string>; engines: Record<string, string>; files: string[]; scripts: Record<string, string> };
|
||||
expect(pkg.bin.storebound).toBe('dist/storebound.mjs');
|
||||
|
|
@ -151,3 +164,15 @@ describe('rt: serve', () => {
|
|||
expect(rt.packageRoot()).toBe(ROOT);
|
||||
});
|
||||
});
|
||||
|
||||
describe('rt: readLine', () => {
|
||||
test('one line, CRLF trimmed, null at EOF, stream paused afterwards', async () => {
|
||||
const { Readable } = await import('node:stream');
|
||||
const a = Readable.from(['n\r\nmore\n']);
|
||||
expect(await rt.readLine(a)).toBe('n');
|
||||
expect(a.isPaused()).toBe(true);
|
||||
expect(await rt.readLine(Readable.from(['\n']))).toBe('');
|
||||
expect(await rt.readLine(Readable.from([]))).toBe(null);
|
||||
expect(await rt.readLine(Readable.from(['yes']))).toBe('yes');
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue