Download packages/migration-legacy/test/atomic-write.test.ts from SaylorTwift/kimi-code: direct link, hf CLI and curl.
- Browser
- Download file 963 Bytes
-
https://huggingface.co/SaylorTwift/kimi-code/resolve/main/packages/migration-legacy/test/atomic-write.test.ts
- Command line
-
hf download hf://SaylorTwift/kimi-code/packages/migration-legacy/test/atomic-write.test.ts
-
curl -L -o atomic-write.test.ts https://huggingface.co/SaylorTwift/kimi-code/resolve/main/packages/migration-legacy/test/atomic-write.test.ts
963 Bytes
| import { describe, expect, it, beforeEach, afterEach } from 'vitest'; | |
| import { mkdtemp, readFile, rm, stat } from 'node:fs/promises'; | |
| import { tmpdir } from 'node:os'; | |
| import { join } from 'node:path'; | |
| import { atomicWrite } from '../src/atomic-write.js'; | |
| let dir: string; | |
| beforeEach(async () => { | |
| dir = await mkdtemp(join(tmpdir(), 'atomic-write-')); | |
| }); | |
| afterEach(async () => { | |
| await rm(dir, { recursive: true, force: true }); | |
| }); | |
| describe('atomicWrite', () => { | |
| it.skipIf(process.platform === 'win32')('writes the target file with private 0600 permissions', async () => { | |
| // Migrated config files carry provider API keys — they must not be | |
| // group/world-readable regardless of the target directory's mode. | |
| const path = join(dir, 'config.toml'); | |
| await atomicWrite(path, 'api_key = "secret"\n'); | |
| expect(await readFile(path, 'utf-8')).toBe('api_key = "secret"\n'); | |
| expect((await stat(path)).mode & 0o777).toBe(0o600); | |
| }); | |
| }); | |