|
1 | 1 | import { getStorageConfig } from '@auth/provider.js'; |
2 | 2 | import { bundle } from '@tigrisdata/storage'; |
3 | 3 | import { exitWithError } from '@utils/exit.js'; |
4 | | -import { getFormat, getOption } from '@utils/options.js'; |
| 4 | +import { getFormat, getOption, readStdin } from '@utils/options.js'; |
5 | 5 | import { parseAnyPath } from '@utils/path.js'; |
6 | 6 | import { createWriteStream, existsSync, readFileSync } from 'fs'; |
7 | 7 | import { Readable } from 'stream'; |
8 | 8 | import { pipeline } from 'stream/promises'; |
9 | 9 |
|
10 | 10 | const MAX_KEYS = 5000; |
11 | 11 |
|
12 | | -async function readStdin(): Promise<string> { |
13 | | - const chunks: Buffer[] = []; |
14 | | - for await (const chunk of process.stdin) { |
15 | | - chunks.push(chunk); |
16 | | - } |
17 | | - return Buffer.concat(chunks).toString('utf-8'); |
18 | | -} |
19 | | - |
20 | 12 | function parseKeys(content: string): string[] { |
21 | 13 | return content |
22 | 14 | .split('\n') |
@@ -65,13 +57,18 @@ export default async function bundleCommand(options: Record<string, unknown>) { |
65 | 57 | let keys: string[]; |
66 | 58 |
|
67 | 59 | if (keysArg) { |
68 | | - if (existsSync(keysArg)) { |
69 | | - keys = parseKeys(readFileSync(keysArg, 'utf-8')); |
70 | | - } else { |
| 60 | + if (keysArg.includes(',')) { |
| 61 | + // Commas present → always treat as inline comma-separated keys |
71 | 62 | keys = keysArg |
72 | 63 | .split(',') |
73 | 64 | .map((k) => k.trim()) |
74 | 65 | .filter((k) => k.length > 0); |
| 66 | + } else if (existsSync(keysArg)) { |
| 67 | + // No commas and local file exists → read as keys file |
| 68 | + keys = parseKeys(readFileSync(keysArg, 'utf-8')); |
| 69 | + } else { |
| 70 | + // Single key |
| 71 | + keys = [keysArg.trim()]; |
75 | 72 | } |
76 | 73 | } else if (!process.stdin.isTTY) { |
77 | 74 | const input = await readStdin(); |
|
0 commit comments