Add .gitignore to exclude all node packages and lock files
This commit is contained in:
+87
@@ -0,0 +1,87 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.printCodeFrameAndStack = void 0;
|
||||
const chalk_1 = require("./chalk");
|
||||
const log_1 = require("./log");
|
||||
const truthy_1 = require("./truthy");
|
||||
const makeFileName = (firstFrame) => {
|
||||
return [
|
||||
firstFrame.originalFileName,
|
||||
firstFrame.originalLineNumber,
|
||||
firstFrame.originalColumnNumber === 0
|
||||
? null
|
||||
: firstFrame.originalColumnNumber,
|
||||
]
|
||||
.filter(truthy_1.truthy)
|
||||
.join(':');
|
||||
};
|
||||
const printCodeFrame = (frame, logLevel) => {
|
||||
if (!frame.originalScriptCode) {
|
||||
return;
|
||||
}
|
||||
log_1.Log.info({ indent: false, logLevel });
|
||||
const longestLineNumber = Math.max(...frame.originalScriptCode.map((script) => script.lineNumber)).toString().length;
|
||||
log_1.Log.info({ indent: false, logLevel }, 'at', chalk_1.chalk.underline(makeFileName(frame)));
|
||||
const alignLeftAmount = Math.min(...frame.originalScriptCode.map((c) => c.content.length - c.content.trimStart().length));
|
||||
log_1.Log.info({ indent: false, logLevel }, `${frame.originalScriptCode
|
||||
.map((c) => {
|
||||
const left = String(c.lineNumber).padStart(longestLineNumber, ' ');
|
||||
const right = c.content.substring(alignLeftAmount);
|
||||
if (c.highlight) {
|
||||
return `${left} │ ${right}`;
|
||||
}
|
||||
return `${chalk_1.chalk.gray(left)} │ ${chalk_1.chalk.gray(right)}`;
|
||||
})
|
||||
.join('\n')}`);
|
||||
};
|
||||
const logLine = (frame, logLevel) => {
|
||||
const fileName = makeFileName(frame);
|
||||
if (!fileName) {
|
||||
return;
|
||||
}
|
||||
log_1.Log.info({ indent: false, logLevel }, chalk_1.chalk.gray(['at', frame.originalFunctionName, `${chalk_1.chalk.blueBright(`(${fileName})`)}`]
|
||||
.filter(truthy_1.truthy)
|
||||
.join(' ')));
|
||||
};
|
||||
const printCodeFrameAndStack = ({ symbolicated, logLevel, }) => {
|
||||
var _a, _b, _c, _d, _e;
|
||||
if (!symbolicated.symbolicatedStackFrames ||
|
||||
symbolicated.symbolicatedStackFrames.length === 0) {
|
||||
log_1.Log.error({ indent: false, logLevel }, symbolicated.stack);
|
||||
return;
|
||||
}
|
||||
const firstFrame = symbolicated.symbolicatedStackFrames[0];
|
||||
log_1.Log.error({ indent: false, logLevel }, chalk_1.chalk.bgRed(chalk_1.chalk.white(` ${symbolicated.name} `)), symbolicated.message);
|
||||
printCodeFrame(firstFrame, logLevel);
|
||||
log_1.Log.info({ indent: false, logLevel });
|
||||
for (const frame of symbolicated.symbolicatedStackFrames) {
|
||||
if (frame === firstFrame) {
|
||||
continue;
|
||||
}
|
||||
const isUserCode = !((_a = frame.originalFileName) === null || _a === void 0 ? void 0 : _a.includes('node_modules')) &&
|
||||
!((_b = frame.originalFileName) === null || _b === void 0 ? void 0 : _b.startsWith('webpack/'));
|
||||
if (isUserCode) {
|
||||
printCodeFrame(frame, logLevel);
|
||||
}
|
||||
else {
|
||||
logLine(frame, logLevel);
|
||||
}
|
||||
}
|
||||
if (symbolicated.delayRenderCall) {
|
||||
log_1.Log.error({ indent: false, logLevel });
|
||||
log_1.Log.error({ indent: false, logLevel }, '🕧 The delayRender() call is located at:');
|
||||
for (const frame of symbolicated.delayRenderCall) {
|
||||
const showCodeFrame = (!((_c = frame.originalFileName) === null || _c === void 0 ? void 0 : _c.includes('node_modules')) &&
|
||||
!((_d = frame.originalFileName) === null || _d === void 0 ? void 0 : _d.startsWith('webpack/'))) ||
|
||||
frame === symbolicated.delayRenderCall[0] ||
|
||||
((_e = frame.originalScriptCode) === null || _e === void 0 ? void 0 : _e.map((c) => c.content).join('').includes('delayRender'));
|
||||
if (showCodeFrame) {
|
||||
printCodeFrame(frame, logLevel);
|
||||
}
|
||||
else {
|
||||
logLine(frame, logLevel);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
exports.printCodeFrameAndStack = printCodeFrameAndStack;
|
||||
Reference in New Issue
Block a user