( directory: string, filename: string, contents: string, )
| 25 | } |
| 26 | |
| 27 | export async function writeSecureTempFile( |
| 28 | directory: string, |
| 29 | filename: string, |
| 30 | contents: string, |
| 31 | ): Promise<string> { |
| 32 | if (!isSimpleLeafName(filename)) { |
| 33 | throw new Error('Secure temporary file names must be simple leaf names'); |
| 34 | } |
| 35 | |
| 36 | const filePath = path.join(directory, filename); |
| 37 | await fs.writeFile(filePath, contents, SECURE_FILE_OPTIONS); |
| 38 | return filePath; |
| 39 | } |
| 40 | |
| 41 | export async function removeSecureTempDirectory(directory: string): Promise<void> { |
| 42 | await fs.rm(directory, { force: true, recursive: true }); |
no test coverage detected
searching dependent graphs…