create-yeow 0.2.27 → 0.2.29
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
|
|
@@ -116,7 +116,7 @@ async function initServer() {
|
|
|
116
116
|
}
|
|
117
117
|
writeFileSync(eula, 'eula=true\n'); ok('EULA auto-accepted');
|
|
118
118
|
} else {
|
|
119
|
-
console.log(
|
|
119
|
+
console.log(`\n Press Enter to accept EULA:`);
|
|
120
120
|
await new Promise(r => process.stdin.once('data', () => { writeFileSync(eula, 'eula=true\n'); ok('EULA accepted'); r(); }));
|
|
121
121
|
}
|
|
122
122
|
}
|
|
@@ -198,51 +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
|
-
|
|
201
|
+
let out = `\n${c.R}${c.B} JS Error [${err.plugin}]${c.r}\n`;
|
|
202
|
+
out += ` ${c.Y}${err.message}${c.r}\n`;
|
|
203
203
|
|
|
204
|
-
|
|
205
|
-
if (
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
if (
|
|
209
|
-
const
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
const
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
const
|
|
218
|
-
|
|
219
|
-
const prefix = i === orig.line - 1 ? c.R + ' →' : ' ';
|
|
220
|
-
console.log(` ${prefix} ${c.D}${String(i + 1).padStart(4)}|${c.r} ${lines[i]}`);
|
|
221
|
-
}
|
|
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`;
|
|
222
219
|
}
|
|
223
220
|
}
|
|
224
221
|
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
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;
|
|
237
234
|
}
|
|
238
|
-
console.log(` ${c.D} ${line}${c.r}`);
|
|
239
235
|
}
|
|
236
|
+
out += ` ${c.D} ${line}${c.r}\n`;
|
|
240
237
|
}
|
|
241
|
-
} else if (err.stack) {
|
|
242
|
-
err.stack.split('\n').slice(0, 5).forEach(l => console.log(` ${c.D} ${l.trim()}${c.r}`));
|
|
243
238
|
}
|
|
239
|
+
} else if (err.stack) {
|
|
240
|
+
err.stack.split('\n').slice(0, 5).forEach(l => { out += ` ${c.D} ${l.trim()}${c.r}\n`; });
|
|
244
241
|
}
|
|
245
|
-
console.log();
|
|
242
|
+
console.log(out);
|
|
246
243
|
}
|
|
247
244
|
|
|
248
245
|
function startServer() {
|