| 204 | let tmpRoot; |
| 205 | |
| 206 | function makeVersionedLayout(prefix, versions, subdir) { |
| 207 | // Mirror the on-disk layout of one Node version manager into a tmpdir. |
| 208 | // Each `versions/<ver>/<subdir>/node_modules` lives as a real directory |
| 209 | // so the scanner's fs.statSync call works. |
| 210 | const root = path.join(tmpRoot, prefix); |
| 211 | for (const v of versions) { |
| 212 | const versionDir = path.join(root, v); |
| 213 | const nmDir = path.join(versionDir, subdir, 'node_modules'); |
| 214 | fs.mkdirSync(nmDir, { recursive: true }); |
| 215 | } |
| 216 | return root; |
| 217 | } |
| 218 | |
| 219 | function setup() { |
| 220 | tmpRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'evolver-runtime-paths-')); |