create-yeow 0.2.42 → 0.2.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
Binary file
|
|
@@ -203,48 +203,65 @@ async function printFormattedError(err) {
|
|
|
203
203
|
out += ` ${c.Y}${err.message}${c.r}\n`;
|
|
204
204
|
|
|
205
205
|
const consumer = (err.fileName === 'main.js' || err.stack) ? await getSourceMapConsumer() : null;
|
|
206
|
-
if (consumer) {
|
|
207
|
-
if (err.
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
const indent = ' '.repeat(String(i + 1).padStart(4).length) + '| ';
|
|
223
|
-
const caret = ' '.repeat(col) + c.R + '^' + c.r;
|
|
224
|
-
out += ` ${c.R} →${c.r} ${indent}${caret}\n`;
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
}
|
|
206
|
+
if (!consumer) {
|
|
207
|
+
if (err.stack) err.stack.split('\n').slice(0, 5).forEach(l => { out += ` ${c.D} ${l.trim()}${c.r}\n`; });
|
|
208
|
+
console.log(out);
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// Resolve all stack frames
|
|
213
|
+
const frames = [];
|
|
214
|
+
if (err.stack) {
|
|
215
|
+
for (const line of err.stack.split('\n')) {
|
|
216
|
+
const m = line.match(/at\s+(?:\S+\s+)?\(?(?:\/main\.js|[^:]+):(\d+):(\d+)\)?/);
|
|
217
|
+
if (m) {
|
|
218
|
+
const orig = consumer.originalPositionFor({ line: parseInt(m[1]), column: parseInt(m[2]) });
|
|
219
|
+
frames.push({ orig, raw: line });
|
|
220
|
+
} else {
|
|
221
|
+
frames.push({ raw: line });
|
|
228
222
|
}
|
|
229
223
|
}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// Find first frame from user's src/ directory (not node_modules)
|
|
227
|
+
let ctxFrame = frames.find(f => f.orig?.source?.match(/[\\/]src[\\/]/) && !f.orig.source.includes('node_modules'))?.orig || null;
|
|
228
|
+
if (!ctxFrame && err.lineNumber > 0) {
|
|
229
|
+
ctxFrame = consumer.originalPositionFor({ line: err.lineNumber, column: err.columnNumber || 0 });
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// Show context for the chosen frame
|
|
233
|
+
if (ctxFrame?.source && ctxFrame.line) {
|
|
234
|
+
const srcPath = ctxFrame.source.replace(/^\.\.\/\.\.\//, '');
|
|
235
|
+
out += ` ${c.C}at ${srcPath}:${ctxFrame.line}:${ctxFrame.column}${c.r}\n`;
|
|
236
|
+
const content = consumer.sourceContentFor(ctxFrame.source);
|
|
237
|
+
if (content) {
|
|
238
|
+
const lines = content.split('\n');
|
|
239
|
+
const start = Math.max(0, ctxFrame.line - 3);
|
|
240
|
+
const end = Math.min(lines.length, ctxFrame.line + 2);
|
|
241
|
+
for (let i = start; i < end; i++) {
|
|
242
|
+
const prefix = i === ctxFrame.line - 1 ? c.R + ' →' : ' ';
|
|
243
|
+
out += ` ${prefix} ${c.D}${String(i + 1).padStart(4)}|${c.r} ${lines[i]}\n`;
|
|
244
|
+
if (i === ctxFrame.line - 1 && ctxFrame.column > 0) {
|
|
245
|
+
const col = Math.max(0, ctxFrame.column);
|
|
246
|
+
const indent = ' '.repeat(String(i + 1).padStart(4).length) + '| ';
|
|
247
|
+
const caret = ' '.repeat(col) + c.R + '^' + c.r;
|
|
248
|
+
out += ` ${c.R} →${c.r} ${indent}${caret}\n`;
|
|
242
249
|
}
|
|
243
|
-
out += ` ${c.D} ${line}${c.r}\n`;
|
|
244
250
|
}
|
|
245
251
|
}
|
|
246
|
-
}
|
|
247
|
-
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// Print resolved stack (all frames)
|
|
255
|
+
if (frames.length > 0) {
|
|
256
|
+
out += ` ${c.D}Stack:${c.r}\n`;
|
|
257
|
+
for (const f of frames) {
|
|
258
|
+
if (f.orig?.source) {
|
|
259
|
+
const srcPath = f.orig.source.replace(/^\.\.\/\.\.\//, '');
|
|
260
|
+
out += ` ${c.D} at ${srcPath}:${f.orig.line}:${f.orig.column}${c.r}\n`;
|
|
261
|
+
} else {
|
|
262
|
+
out += ` ${c.D} ${f.raw}${c.r}\n`;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
248
265
|
}
|
|
249
266
|
console.log(out);
|
|
250
267
|
}
|