UNPKG

998 BJavaScriptView Raw
1"use strict";
2/**
3 * @license
4 * Copyright Google LLC All Rights Reserved.
5 *
6 * Use of this source code is governed by an MIT-style license that can be
7 * found in the LICENSE file at https://angular.io/license
8 */
9Object.defineProperty(exports, "__esModule", { value: true });
10exports.writeErrorToLogFile = void 0;
11const fs_1 = require("fs");
12const os_1 = require("os");
13const path_1 = require("path");
14let logPath;
15/**
16 * Writes an Error to a temporary log file.
17 * If this method is called multiple times from the same process the same log file will be used.
18 * @returns The path of the generated log file.
19 */
20function writeErrorToLogFile(error) {
21 if (!logPath) {
22 const tempDirectory = fs_1.mkdtempSync(fs_1.realpathSync(os_1.tmpdir()) + '/ng-');
23 logPath = path_1.normalize(tempDirectory + '/angular-errors.log');
24 }
25 fs_1.appendFileSync(logPath, '[error] ' + (error.stack || error) + '\n\n');
26 return logPath;
27}
28exports.writeErrorToLogFile = writeErrorToLogFile;