MCPcopy Create free account
hub / github.com/danvk/source-map-explorer / writeHtmlToTempFile

Function writeHtmlToTempFile

src/cli/cli.ts:221–245  ·  view source on GitHub ↗

* Write HTML content to a temporary file and open the file in a browser

(html?: string)

Source from the content-addressed store, hash-verified

219 * Write HTML content to a temporary file and open the file in a browser
220 */
221async function writeHtmlToTempFile(html?: string): Promise<void> {
222 if (!html) {
223 return;
224 }
225
226 try {
227 const tempFile = temp.path({ prefix: 'sme-result-', suffix: '.html' });
228
229 fs.writeFileSync(tempFile, html);
230
231 const childProcess = await open(tempFile);
232
233 if (childProcess.stderr) {
234 // Catch error output from child process
235 childProcess.stderr.once('data', (error: Buffer) => {
236 // TODO: Figure out why `#< CLIXML` ends up in stderr. Maybe we should simply ignore it
237 if (error.toString().trim() !== '#< CLIXML') {
238 logError({ code: 'CannotOpenTempFile', tempFile, error });
239 }
240 });
241 }
242 } catch (error) {
243 throw new AppError({ code: 'CannotCreateTempFile' }, error);
244 }
245}
246
247function outputErrors({ errors }: ExploreResult): void {
248 if (errors.length === 0) {

Callers 1

cli.tsFile · 0.85

Calls 1

logErrorFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…