tailwindcss/jest/runInTempDirectory.js
Adam Wathan b299b6fbe1
Support new presets key + extending core plugins config (#2474)
* WIP

* Support array for Tailwind config

* Drop array format for `presets` key instead

* Update changelog
2020-10-08 11:21:39 -04:00

24 lines
509 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(tmpPath, resolve)
})
})
}