mirror of
https://github.com/di-sukharev/opencommit.git
synced 2026-01-13 15:47:58 -05:00
refactor(config.ts): rename configFromEnv to envConfig for better readability refactor(gemini.ts): simplify client initialization in the Gemini constructor test(config.test.ts): add test case to check overriding global config with null values in local .env test(gemini.test.ts): update AI provider assignment to use OCO_AI_PROVIDER_ENUM for consistency
31 lines
739 B
TypeScript
31 lines
739 B
TypeScript
import path from 'path';
|
|
import { mkdtemp, rm, writeFile } from 'fs';
|
|
import { promisify } from 'util';
|
|
import { tmpdir } from 'os';
|
|
const fsMakeTempDir = promisify(mkdtemp);
|
|
const fsRemove = promisify(rm);
|
|
const fsWriteFile = promisify(writeFile);
|
|
|
|
/**
|
|
* Prepare tmp file for the test
|
|
*/
|
|
export async function prepareFile(
|
|
fileName: string,
|
|
content: string
|
|
): Promise<{
|
|
filePath: string;
|
|
cleanup: () => Promise<void>;
|
|
}> {
|
|
const tempDir = await fsMakeTempDir(path.join(tmpdir(), 'opencommit-test-'));
|
|
const filePath = path.resolve(tempDir, fileName);
|
|
await fsWriteFile(filePath, content);
|
|
const cleanup = async () => {
|
|
return fsRemove(tempDir, { recursive: true });
|
|
};
|
|
|
|
return {
|
|
filePath,
|
|
cleanup
|
|
};
|
|
}
|