/
githubmirror
/
tailwindcss
Обзор
Документация
Войти
/
githubmirror
/
tailwindcss
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
v3.4.19
jest/runInTempDirectory.js
26 строк
569 B
Robin Malfait
Drop support for Node.js v12 (#11089)
25 апр 2023, 23:28
Не верифицирован
25 апр 2023, 23:28
bd0497f
Код
Авторство
О чём код?
import fs from 'fs/promises' import path from 'path' import { rimraf } from 'rimraf' let id = 0 /** * @template T * @param {() => Promise<T>} callback * @returns {Promise<T>} */ export default async function (callback) { const workerId = `${process.env.JEST_WORKER_ID}-${id++}` const tmpPath = path.resolve(__dirname, `../__tmp_${workerId}`) const currentPath = process.cwd() await rimraf(tmpPath) await fs.mkdir(tmpPath) process.chdir(tmpPath) let result = await callback() process.chdir(currentPath) await rimraf(tmpPath) return result }