Skip to content

Commit 0954cfd

Browse files
committed
🐛 Fix error stack trace and process output
1 parent b2ecb4a commit 0954cfd

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

bin/index.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ process.on('uncaughtException', printError);
4242
if(!s.test("-f", filepath)) $.error(`File '${candidate}' not found.`);
4343
$.is_fatal= is_fatal;
4444
if(config_env.rc && !$.is_local)
45-
await import("./config.mjs").then(c=> c.importRC()).then(processRC).catch(()=> {});
45+
await import("./config.mjs").then(c=> c.importRC()).then(processRC);
4646
await import(url.pathToFileURL(filepath).toString());
4747
if(is_tmp) s.rm("-f", filepath_tmp);
4848
} catch(e){

src/Error.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ globalThis.Error= class extends ErrorOld{
2929
constructor(message, options){
3030
super(message, options);
3131
const [ lm, ...l ]= Error.stackToList(this.stack);
32-
const i= l.findIndex(l=> l.indexOf("nodejsscript")===-1 || l.indexOf("nodejsscript/examples")!==-1);
32+
const i= l.findIndex(l=> !l.includes("nodejsscript") || l.startsWith("file://"));
3333
const l_out= l.slice(i).filter(l=> !l.includes("node:internal") && !l.includes("nodejsscript/bin/") && !l.includes("async Promise.all (index 0)"));
3434
if(!l_out.length) l_out.push(process.argv[1]);
3535
this.stack= lm+Error.listToStack(l_out);
@@ -50,7 +50,7 @@ export class ProcessOutput extends Error {
5050
for(const [ k, value ] of Object.entries(rest))
5151
Reflect.defineProperty(this, k, { value, writable: false });
5252
Reflect.defineProperty(this, "exitCode", { value: code, writable: false });
53-
const combined= rest.stdout + ( rest.stderr ? "\n"+rest.stderr : "");
54-
Reflect.defineProperty(this, "toString", { value: ()=> combined, writable: false });
53+
const combined= ()=> rest.stdout + ( rest.stderr ? "\n"+rest.stderr : "");
54+
Reflect.defineProperty(this, "toString", { value: combined, writable: false });
5555
}
5656
}

0 commit comments

Comments
 (0)