| 1112 | } |
| 1113 | |
| 1114 | export function getRandomTempFolder(): string { |
| 1115 | const r = Math.floor(Math.random() * 100000); |
| 1116 | const base = path.join(tmpdir(), "dart-code-tests"); |
| 1117 | if (!fs.existsSync(base)) |
| 1118 | fs.mkdirSync(base); |
| 1119 | const tmpPath = path.join(base, r.toString()); |
| 1120 | if (!fs.existsSync(tmpPath)) |
| 1121 | fs.mkdirSync(tmpPath); |
| 1122 | return tmpPath; |
| 1123 | } |
| 1124 | |
| 1125 | export function createTempPubPackage(packageName: string, folderName = "temp_package"): string { |
| 1126 | const tempFolder = getRandomTempFolder(); |