2019-03-20 08:17:56 -05:00
|
|
|
import fs from 'fs'
|
|
|
|
|
import path from 'path'
|
|
|
|
|
|
|
|
|
|
import rimraf from 'rimraf'
|
|
|
|
|
|
|
|
|
|
export default function(callback) {
|
|
|
|
|
return new Promise(resolve => {
|
2019-05-09 13:29:48 +02:00
|
|
|
const workerId = process.env.JEST_WORKER_ID
|
|
|
|
|
const tmpPath = path.resolve(__dirname, `../__tmp_${workerId}`)
|
2019-03-20 08:17:56 -05:00
|
|
|
const currentPath = process.cwd()
|
|
|
|
|
|
|
|
|
|
rimraf.sync(tmpPath)
|
|
|
|
|
fs.mkdirSync(tmpPath)
|
|
|
|
|
process.chdir(tmpPath)
|
|
|
|
|
|
|
|
|
|
callback().then(() => {
|
|
|
|
|
process.chdir(currentPath)
|
|
|
|
|
rimraf(tmpPath, resolve)
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
}
|