create-yeow 0.2.26 → 0.2.28
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
|
|
@@ -198,57 +198,48 @@ async function getSourceMapConsumer() {
|
|
|
198
198
|
|
|
199
199
|
async function printFormattedError(err) {
|
|
200
200
|
const c = { r: '\x1b[0m', R: '\x1b[31m', Y: '\x1b[33m', C: '\x1b[36m', B: '\x1b[1m', D: '\x1b[2m' };
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
console.log(` ${c.D}at ${err.fileName}:${err.lineNumber}:${err.columnNumber}${c.r}`);
|
|
201
|
+
let out = `\n${c.R}${c.B} ⛔ JS Error [${err.plugin}]${c.r}\n`;
|
|
202
|
+
out += ` ${c.Y}${err.message}${c.r}\n`;
|
|
204
203
|
|
|
205
|
-
|
|
206
|
-
if (
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
if (
|
|
210
|
-
const
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
const
|
|
215
|
-
const
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
const start = Math.max(0, orig.line - 3);
|
|
221
|
-
const end = Math.min(lines.length, orig.line + 2);
|
|
222
|
-
for (let i = start; i < end; i++) {
|
|
223
|
-
const prefix = i === orig.line - 1 ? c.R + ' →' : ' ';
|
|
224
|
-
console.log(` ${prefix} ${c.D}${String(i + 1).padStart(4)}|${c.r} ${lines[i]}`);
|
|
225
|
-
}
|
|
226
|
-
}
|
|
204
|
+
const consumer = (err.fileName === 'main.js' || err.stack) ? await getSourceMapConsumer() : null;
|
|
205
|
+
if (consumer) {
|
|
206
|
+
if (err.lineNumber > 0) {
|
|
207
|
+
const orig = consumer.originalPositionFor({ line: err.lineNumber, column: err.columnNumber || 0 });
|
|
208
|
+
if (orig.source && orig.line) {
|
|
209
|
+
const srcPath = orig.source.replace(/^\.\.\/\.\.\//, '');
|
|
210
|
+
out += ` ${c.C}at ${srcPath}:${orig.line}:${orig.column}${c.r}\n`;
|
|
211
|
+
const content = consumer.sourceContentFor(orig.source);
|
|
212
|
+
if (content) {
|
|
213
|
+
const lines = content.split('\n');
|
|
214
|
+
const start = Math.max(0, orig.line - 3);
|
|
215
|
+
const end = Math.min(lines.length, orig.line + 2);
|
|
216
|
+
for (let i = start; i < end; i++) {
|
|
217
|
+
const prefix = i === orig.line - 1 ? c.R + ' →' : ' ';
|
|
218
|
+
out += ` ${prefix} ${c.D}${String(i + 1).padStart(4)}|${c.r} ${lines[i]}\n`;
|
|
227
219
|
}
|
|
228
220
|
}
|
|
229
221
|
}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
}
|
|
222
|
+
}
|
|
223
|
+
if (err.stack) {
|
|
224
|
+
const stackLines = err.stack.split('\n');
|
|
225
|
+
for (let i = 0; i < Math.min(stackLines.length, 8); i++) {
|
|
226
|
+
const line = stackLines[i].trim();
|
|
227
|
+
const m = line.match(/at\s+(?:\S+\s+)?\(?(?:\/main\.js|[^:]+):(\d+):(\d+)\)?/);
|
|
228
|
+
if (m) {
|
|
229
|
+
const orig = consumer.originalPositionFor({ line: parseInt(m[1]), column: parseInt(m[2]) });
|
|
230
|
+
if (orig.source) {
|
|
231
|
+
const srcPath = orig.source.replace(/^\.\.\/\.\.\//, '');
|
|
232
|
+
out += ` ${c.D} at ${srcPath}:${orig.line}:${orig.column}${c.r}\n`;
|
|
233
|
+
continue;
|
|
243
234
|
}
|
|
244
|
-
console.log(` ${c.D} ${line}${c.r}`);
|
|
245
235
|
}
|
|
236
|
+
out += ` ${c.D} ${line}${c.r}\n`;
|
|
246
237
|
}
|
|
247
|
-
} else if (err.stack) {
|
|
248
|
-
err.stack.split('\n').slice(0, 5).forEach(l => console.log(` ${c.D} ${l.trim()}${c.r}`));
|
|
249
238
|
}
|
|
239
|
+
} else if (err.stack) {
|
|
240
|
+
err.stack.split('\n').slice(0, 5).forEach(l => { out += ` ${c.D} ${l.trim()}${c.r}\n`; });
|
|
250
241
|
}
|
|
251
|
-
console.log();
|
|
242
|
+
console.log(out);
|
|
252
243
|
}
|
|
253
244
|
|
|
254
245
|
function startServer() {
|