2022-04-23 18:41:14 +02:00
|
|
|
import { fileURLToPath } from 'node:url'
|
2021-07-03 18:40:17 +02:00
|
|
|
import fs from 'node:fs'
|
2021-06-09 20:31:45 +02:00
|
|
|
|
2022-02-19 18:30:29 +01:00
|
|
|
import { isExistingPath } from '../utils/isExistingPath.js'
|
2021-06-09 20:31:45 +02:00
|
|
|
|
2022-04-23 18:41:14 +02:00
|
|
|
export const TEMPORARY_URL = new URL('../../temp', import.meta.url)
|
|
|
|
export const TEMPORARY_PATH = fileURLToPath(TEMPORARY_URL)
|
2021-06-09 20:31:45 +02:00
|
|
|
|
|
|
|
export const createTemporaryEmptyFolder = async (): Promise<void> => {
|
|
|
|
if (await isExistingPath(TEMPORARY_PATH)) {
|
2022-04-23 18:41:14 +02:00
|
|
|
await fs.promises.rm(TEMPORARY_URL, { recursive: true, force: true })
|
2021-06-09 20:31:45 +02:00
|
|
|
}
|
2022-04-23 18:41:14 +02:00
|
|
|
await fs.promises.mkdir(TEMPORARY_URL)
|
2021-06-09 20:31:45 +02:00
|
|
|
}
|