tailwindcss/jest/runInTempDirectory.js
Robin Malfait 66c640b735
Upgrade rimraf: 3.0.2 → 4.1.2 (major) (#10596)
* Update rimraf to version 4.1.2

* use rimraf sync API

Our `oxide` engine uses rimraf v4, our `stable` engine uses rimraf v3
and the API is different in both. However the tests are currently shared
for both engines so we have to use the correct API for the correct
version.

However, we can also just use the `sync` API.

More info: https://github.com/isaacs/rimraf#major-changes-from-v3-to-v4

---------

Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com>
2023-02-16 00:52:36 +01:00

26 lines
525 B
JavaScript

import fs from 'fs'
import path from 'path'
import rimraf from 'rimraf'
let id = 0
export default function (callback) {
return new Promise((resolve) => {
const workerId = `${process.env.JEST_WORKER_ID}-${id++}`
const tmpPath = path.resolve(__dirname, `../__tmp_${workerId}`)
const currentPath = process.cwd()
rimraf.sync(tmpPath)
fs.mkdirSync(tmpPath)
process.chdir(tmpPath)
callback().then(() => {
process.chdir(currentPath)
rimraf.sync(tmpPath)
resolve()
})
})
}