| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | 1x 1x 1x 1x 1x 3x 3x 3x 3x 3x 3x 2x 2x 1x | const path = require('path')
const uuid = require('uuid')
const fs = require('fs-extra')
const log = require('../../log')
const prepareTestLocation = label => {
const location = path.join('tmp', `${uuid.v4()}-${label}`)
return {
location,
cleanup: async () => {
log.info('Cleaning up...')
await fs.remove(location)
const files = await fs.readdir('tmp')
if (!files.length) {
await fs.remove('tmp')
}
log.info('... cleaned up.')
}
}
}
module.exports = prepareTestLocation
|