Skip to content

Commit 63222fb

Browse files
author
Raylan LIN
committed
fix: Node.js compatibility for file upload and status bar
- Replace Bun.file() with fs/promises.readFile() in file/upload.ts - Export resetStatusBar() function to fix test state pollution (Issue #9) These changes make the CLI work in pure Node.js environments without Bun.
1 parent 5ab315c commit 63222fb

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

src/commands/file/upload.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import type { Config } from '../../config/schema';
1010
import type { GlobalFlags } from '../../types/flags';
1111
import type { FileUploadResponse } from '../../types/api';
1212
import { existsSync } from 'fs';
13-
import { resolve } from 'path';
13+
import { readFile } from 'fs/promises';
14+
import { resolve, basename } from 'path';
1415

1516
export default defineCommand({
1617
name: 'file upload',
@@ -53,9 +54,9 @@ export default defineCommand({
5354
}
5455

5556
const formData = new FormData();
56-
// Read file as a Blob-like File object for fetch compatibility
57-
const fileData = await Bun.file(fullPath).arrayBuffer();
58-
const fileName = fullPath.split('/').pop() || 'file';
57+
// Read file using Node.js fs/promises (compatible with both Node and Bun)
58+
const fileData = await readFile(fullPath);
59+
const fileName = basename(fullPath);
5960
const fileBlob = new Blob([fileData]);
6061
formData.append('file', fileBlob, fileName);
6162
formData.append('purpose', purpose);

src/output/status-bar.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ import { maskToken } from '../utils/token';
44

55
let printed = false;
66

7+
export function resetStatusBar(): void {
8+
printed = false;
9+
}
10+
711
const reset = '\x1b[0m';
812
const dim = '\x1b[2m';
913
const bold = '\x1b[1m';

0 commit comments

Comments
 (0)