( params: LocalOutboxEmail, outboxDirectory?: string )
| 65 | } |
| 66 | |
| 67 | export async function writeEmailToLocalOutbox( |
| 68 | params: LocalOutboxEmail, |
| 69 | outboxDirectory?: string |
| 70 | ): Promise<string> { |
| 71 | const workspaceRoot = await findWorkspaceRoot(process.cwd()); |
| 72 | const directory = outboxDirectory ?? path.join(workspaceRoot, 'dev', 'logs', 'emails'); |
| 73 | await mkdir(directory, { recursive: true, mode: 0o700 }); |
| 74 | await chmod(directory, 0o700); |
| 75 | |
| 76 | const timestamp = new Date().toISOString().replace(/[:.]/g, '-'); |
| 77 | const filePath = path.join(directory, `${timestamp}-${randomUUID()}.html`); |
| 78 | const html = addDevelopmentBanner(params.html, developmentBanner(params)); |
| 79 | await writeFile(filePath, html, { encoding: 'utf8', flag: 'wx', mode: 0o600 }); |
| 80 | if (process.env.LOCAL_EMAIL_OPEN_BROWSER !== 'false') { |
| 81 | openEmail(filePath); |
| 82 | } |
| 83 | return filePath; |
| 84 | } |
no test coverage detected