(pathsOrUris: (string | [string, string])[])
| 27 | ["index/index.ts", "hello"] creates index/index.ts with contents "hello" |
| 28 | */ |
| 29 | export function addToTestDir(pathsOrUris: (string | [string, string])[]) { |
| 30 | // Allow tests to use URIs or local paths |
| 31 | const paths = pathsOrUris.map((val) => { |
| 32 | if (Array.isArray(val)) { |
| 33 | return [localPathOrUriToPath(val[0]), val[1]]; |
| 34 | } else { |
| 35 | return localPathOrUriToPath(val); |
| 36 | } |
| 37 | }); |
| 38 | |
| 39 | for (const p of paths) { |
| 40 | const filepath = path.join(TEST_DIR_PATH, Array.isArray(p) ? p[0] : p); |
| 41 | fs.mkdirSync(path.dirname(filepath), { recursive: true }); |
| 42 | |
| 43 | if (Array.isArray(p)) { |
| 44 | fs.writeFileSync(filepath, p[1]); |
| 45 | } else if (p.endsWith("/")) { |
| 46 | fs.mkdirSync(filepath, { recursive: true }); |
| 47 | } else { |
| 48 | fs.writeFileSync(filepath, ""); |
| 49 | } |
| 50 | } |
| 51 | } |
no test coverage detected