Skip to content

Commit b6c89d5

Browse files
Matt-Dionisclaude
andcommitted
Add crypto.getRandomValues polyfill for Node < 19
- Add polyfill in test setup for older Node.js versions - Fixes Vitest startup error in CI environment - Uses crypto.randomFillSync as fallback implementation - Ensures compatibility with Node.js 16+ as specified 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 55b9255 commit b6c89d5

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

claude-config-composer/tests/setup.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@ import fs from 'fs/promises';
22
import os from 'os';
33
import path from 'path';
44
import { afterAll, beforeAll, beforeEach } from 'vitest';
5+
import crypto from 'crypto';
6+
7+
// Polyfill for crypto.getRandomValues for Node < 19
8+
if (!globalThis.crypto) {
9+
globalThis.crypto = crypto as any;
10+
}
11+
if (!globalThis.crypto.getRandomValues) {
12+
globalThis.crypto.getRandomValues = function(array: any) {
13+
return crypto.randomFillSync(array);
14+
};
15+
}
516

617
export const TEST_TEMP_DIR = path.join(os.tmpdir(), 'claude-config-test');
718

0 commit comments

Comments
 (0)