(contents: string)
| 8 | // A cleanup method is also returned, allowing the consumer to remove the |
| 9 | // mock file. |
| 10 | export const createMock = async (contents: string) => { |
| 11 | const path = temporaryFile({ extension: 'js' }) |
| 12 | |
| 13 | await writeFile(path, contents) |
| 14 | |
| 15 | const env = { |
| 16 | // windows needs 'file://' paths |
| 17 | NETLIFY_CLI_EXECA_PATH: pathToFileURL(path).href, |
| 18 | } |
| 19 | const cleanup = () => |
| 20 | rm(path, { force: true, recursive: true }).catch(() => { |
| 21 | // no-op |
| 22 | }) |
| 23 | |
| 24 | return [env, cleanup] as const |
| 25 | } |
no test coverage detected