mirror of
https://github.com/actions/runner-container-hooks.git
synced 2025-12-14 00:26:44 +00:00
29 lines
684 B
TypeScript
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)
|
|
}
|
|
}
|