/
githubmirror
/
angular-cli
Обзор
Документация
Войти
/
githubmirror
/
angular-cli
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
packages/angular/cli/src/utilities/log-file.ts
29 строк
891 B
Joey Perrott
refactor: move builtin module imports to use node: prefix imports
14 фев 2025, 22:09
14 фев 2025, 22:09
33ed6e8
Код
Авторство
О чём код?
/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.dev/license */ import { appendFileSync, mkdtempSync, realpathSync } from 'node:fs'; import { tmpdir } from 'node:os'; import { normalize } from 'node:path'; let logPath: string | undefined; /** * Writes an Error to a temporary log file. * If this method is called multiple times from the same process the same log file will be used. * @returns The path of the generated log file. */ export function writeErrorToLogFile(error: Error): string { if (!logPath) { const tempDirectory = mkdtempSync(realpathSync(tmpdir()) + '/ng-'); logPath = normalize(tempDirectory + '/angular-errors.log'); } appendFileSync(logPath, '[error] ' + (error.stack || error) + '\n\n'); return logPath; }