strong-tie/inbound-calls
0
1'use strict'2 3const { test, teardown } = require('tap')4const fs = require('fs')5const os = require('os')6const path = require('path')7 8const files = []9let count = 010 11function file () {12 const file = path.join(os.tmpdir(), `sonic-boom-${process.pid}-${process.hrtime().toString()}-${count++}`)13 files.push(file)14 return file15}16 17teardown(() => {18 const rmSync = fs.rmSync || fs.rmdirSync19 files.forEach((file) => {20 try {21 if (fs.existsSync(file)) {22 fs.statSync(file).isDirectory() ? rmSync(file, { recursive: true, maxRetries: 10 }) : fs.unlinkSync(file)23 }24 } catch (e) {25 console.log(e)26 }27 })28})29 30function runTests (buildTests) {31 test('sync false', (t) => {32 buildTests(t.test, false)33 t.end()34 })35 36 test('sync true', (t) => {37 buildTests(t.test, true)38 t.end()39 })40}41 42module.exports = { file, runTests }43 