(useSpawn = false)
| 43 | |
| 44 | let firstRefresh = true; |
| 45 | function refresh(useSpawn = false) { |
| 46 | rmSync(tmpPath, useSpawn); |
| 47 | fs.mkdirSync(tmpPath); |
| 48 | |
| 49 | if (firstRefresh) { |
| 50 | firstRefresh = false; |
| 51 | // Clean only when a test uses refresh. This allows for child processes to |
| 52 | // use the tmpdir and only the parent will clean on exit. |
| 53 | process.on('exit', () => { |
| 54 | return onexit(useSpawn); |
| 55 | }); |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | function onexit(useSpawn) { |
| 60 | // Change directory to avoid possible EBUSY |