1
1
mirror of https://github.com/theoludwig/programming-challenges.git synced 2024-07-18 02:20:12 +02:00
programming-challenges/cli/utils/createTemporaryEmptyFolder.ts

15 lines
494 B
TypeScript
Raw Normal View History

import { fileURLToPath } from 'node:url'
import fs from 'node:fs'
2022-02-19 18:30:29 +01:00
import { isExistingPath } from '../utils/isExistingPath.js'
export const TEMPORARY_URL = new URL('../../temp', import.meta.url)
export const TEMPORARY_PATH = fileURLToPath(TEMPORARY_URL)
export const createTemporaryEmptyFolder = async (): Promise<void> => {
if (await isExistingPath(TEMPORARY_PATH)) {
await fs.promises.rm(TEMPORARY_URL, { recursive: true, force: true })
}
await fs.promises.mkdir(TEMPORARY_URL)
}