Files
runner-container-hooks/packages/k8s/tests/test-setup.ts
2022-06-02 15:53:11 -04:00

29 lines
684 B
TypeScript

import * as fs from 'fs'
import { v4 as uuidv4 } from 'uuid'
export class TestTempOutput {
private tempDirPath: string
constructor() {
this.tempDirPath = `${__dirname}/_temp/${uuidv4()}`
}
public initialize(): void {
fs.mkdirSync(this.tempDirPath, { recursive: true })
}
public cleanup(): void {
fs.rmSync(this.tempDirPath, { recursive: true })
}
public createFile(fileName?: string): string {
const filePath = `${this.tempDirPath}/${fileName || uuidv4()}`
fs.writeFileSync(filePath, '')
return filePath
}
public removeFile(fileName: string): void {
const filePath = `${this.tempDirPath}/${fileName}`
fs.rmSync(filePath)
}
}