UNPKG

961 BJavaScriptView Raw
1"use strict";
2/**
3 * @license
4 * Copyright Google Inc. 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 });
10const fs_1 = require("fs");
11const os_1 = require("os");
12const path_1 = require("path");
13let logPath;
14/**
15 * Writes an Error to a temporary log file.
16 * If this method is called multiple times from the same process the same log file will be used.
17 * @returns The path of the generated log file.
18 */
19function writeErrorToLogFile(error) {
20 if (!logPath) {
21 const tempDirectory = fs_1.mkdtempSync(fs_1.realpathSync(os_1.tmpdir()) + '/ng-');
22 logPath = path_1.normalize(tempDirectory + '/angular-errors.log');
23 }
24 fs_1.appendFileSync(logPath, '[error] ' + (error.stack || error) + '\n\n');
25 return logPath;
26}
27exports.writeErrorToLogFile = writeErrorToLogFile;