mirror of
https://git.tuxpa.in/a/code-server.git
synced 2024-12-26 20:25:25 +00:00
1789cd1bcb
This is to match the other tests that create temp directories. It also lets you clean up test temp directories all at once separately from other non-test temporary directories.
28 lines
677 B
TypeScript
28 lines
677 B
TypeScript
import * as fs from "fs"
|
|
import * as os from "os"
|
|
import * as path from "path"
|
|
|
|
export const loggerModule = {
|
|
field: jest.fn(),
|
|
level: 2,
|
|
logger: {
|
|
debug: jest.fn(),
|
|
error: jest.fn(),
|
|
info: jest.fn(),
|
|
trace: jest.fn(),
|
|
warn: jest.fn(),
|
|
},
|
|
}
|
|
|
|
/**
|
|
* Create a uniquely named temporary directory.
|
|
*
|
|
* These directories are placed under a single temporary code-server directory.
|
|
*/
|
|
export async function tmpdir(testName: string): Promise<string> {
|
|
const dir = path.join(os.tmpdir(), "code-server/tests")
|
|
await fs.promises.mkdir(dir, { recursive: true })
|
|
|
|
return await fs.promises.mkdtemp(path.join(dir, `${testName}-`), { encoding: "utf8" })
|
|
}
|