@tapjs/core
Advanced tools
Comparing version 0.0.0-20 to 0.0.0-21
@@ -55,2 +55,7 @@ "use strict"; | ||
} | ||
if (typeof res.stack === 'string' && | ||
res.stack && | ||
!res.stack.endsWith('\n')) { | ||
res.stack = res.stack.trimEnd() + '\n'; | ||
} | ||
if (res.errorOrigin && typeof res.errorOrigin === 'object') { | ||
@@ -57,0 +62,0 @@ res.errorOrigin = (0, exports.cleanYamlObject)(res.errorOrigin); |
@@ -10,3 +10,3 @@ "use strict"; | ||
//@ts-ignore | ||
if (typeof repl !== 'undefined' || '_eval' in proc_js_1.proc) { | ||
if (typeof repl !== 'undefined' || proc_js_1.proc._forceRepl || '_eval' in proc_js_1.proc) { | ||
return def; | ||
@@ -13,0 +13,0 @@ } |
@@ -12,6 +12,7 @@ "use strict"; | ||
if (isErrorLike(er)) { | ||
const { name, message, stack, error } = er; | ||
const { name, message, stack, error, code } = er; | ||
if (error && typeof error == 'string') | ||
return error; | ||
const nc = name && typeof name === 'string' ? `${name}: ` : ''; | ||
const ncCode = nc && typeof code === 'string' ? `${name} [${code}]: ` : ''; | ||
if (message && typeof message === 'string') | ||
@@ -23,3 +24,5 @@ return message; | ||
? lines[0].substring(nc.length) | ||
: lines[0]; | ||
: ncCode && lines[0].startsWith(ncCode) | ||
? lines[0].substring(ncCode.length) | ||
: lines[0]; | ||
} | ||
@@ -36,3 +39,5 @@ } | ||
typeof er.message !== 'undefined' || | ||
typeof er.stack !== 'undefined'); | ||
typeof er.stack !== 'undefined') && | ||
(er.code === undefined || | ||
typeof er.code === 'string'); | ||
//# sourceMappingURL=message-from-error.js.map |
@@ -307,32 +307,27 @@ "use strict"; | ||
}; | ||
// node 20 doesn't have requests in the same way as node 18 | ||
// we get different objects, handles vs requests, etc. | ||
// it's all very "internal machinery", version specific and unstable | ||
// there are tests to show that we can get SOMETHING in expected cases, | ||
// but it'll be completely differerent across node versions. | ||
/* c8 ignore start */ | ||
if (requests.length) { | ||
extra.requests = requests.map(r => { | ||
/* c8 ignore start */ | ||
if (!r || typeof r !== 'object') | ||
return r; | ||
/* c8 ignore stop */ | ||
const ret = { | ||
type: r.constructor.name, | ||
}; | ||
// most everything in node has a context these days | ||
/* c8 ignore start */ | ||
if (r.context) | ||
ret.context = r.context; | ||
/* c8 ignore stop */ | ||
return ret; | ||
}); | ||
} | ||
// Newer node versions don't have this as reliably. | ||
/* c8 ignore start */ | ||
if (handles.length) { | ||
extra.handles = handles.map(h => { | ||
/* c8 ignore start */ | ||
if (!h || typeof h !== 'object') | ||
return h; | ||
/* c8 ignore stop */ | ||
const ret = { | ||
type: h.constructor.name, | ||
}; | ||
// all of this is very internal-ish | ||
/* c8 ignore start */ | ||
if (h.msecs) | ||
@@ -346,6 +341,6 @@ ret.msecs = h.msecs; | ||
ret.connectionKey = h._connectionKey; | ||
/* c8 ignore stop */ | ||
return ret; | ||
}); | ||
} | ||
/* c8 ignore stop */ | ||
return extra; | ||
@@ -352,0 +347,0 @@ }; |
@@ -839,10 +839,4 @@ "use strict"; | ||
} | ||
this.debug('MAIN pre', this.name); | ||
const end = () => { | ||
this.debug(' > implicit end for promise'); | ||
this.#promiseEnded = true; | ||
this.#end(implicit_end_sigil_js_1.IMPLICIT); | ||
done(); | ||
}; | ||
const done = (er) => { | ||
this.donePromise = undefined; | ||
if (er) | ||
@@ -877,5 +871,12 @@ this.threw(er); | ||
if (ret && ret.then) { | ||
this.donePromise = ret; | ||
ret.tapAbortPromise = done; | ||
ret.then(end, (er) => { | ||
this.donePromise = Object.assign(ret, { | ||
tapAbortPromise: done, | ||
}); | ||
ret.then(() => { | ||
this.debug(' > implicit end for promise'); | ||
this.#promiseEnded = true; | ||
if (!this.ended && !this.#awaitingEnd) | ||
this.#end(implicit_end_sigil_js_1.IMPLICIT); | ||
done(); | ||
}, (er) => { | ||
if (!er || typeof er !== 'object') { | ||
@@ -888,4 +889,5 @@ er = { error: er, at: null }; | ||
} | ||
else | ||
else { | ||
done(); | ||
} | ||
this.debug('MAIN post', this.name); | ||
@@ -1105,5 +1107,6 @@ } | ||
} | ||
if (er.stack && typeof er.stack === 'string') { | ||
if (!extra.stack && er.stack && typeof er.stack === 'string') { | ||
// trim off the first line if it looks like the standard | ||
// error `Name: message` line. | ||
/* c8 ignore start */ | ||
const f = `${er.name || 'Error'}: ${er.message}\n`; | ||
@@ -1113,2 +1116,3 @@ const st = er.stack.startsWith(f) | ||
: er.stack; | ||
/* c8 ignore stop */ | ||
const p = stack.parseStack(st); | ||
@@ -1136,2 +1140,5 @@ extra.at = p[0] || null; | ||
this.#process(); | ||
/* c8 ignore start */ | ||
this.donePromise?.tapAbortPromise?.(); | ||
/* c8 ignore stop */ | ||
} | ||
@@ -1203,4 +1210,3 @@ /** | ||
} | ||
if (this.donePromise && this.donePromise.tapAbortPromise) | ||
this.donePromise.tapAbortPromise(); | ||
this.donePromise?.tapAbortPromise?.(); | ||
for (let i = 0; i < this.queue.length; i++) { | ||
@@ -1207,0 +1213,0 @@ const p = this.queue[i]; |
@@ -29,2 +29,7 @@ import * as stack from '@tapjs/stack'; | ||
} | ||
if (typeof res.stack === 'string' && | ||
res.stack && | ||
!res.stack.endsWith('\n')) { | ||
res.stack = res.stack.trimEnd() + '\n'; | ||
} | ||
if (res.errorOrigin && typeof res.errorOrigin === 'object') { | ||
@@ -31,0 +36,0 @@ res.errorOrigin = cleanYamlObject(res.errorOrigin); |
@@ -7,3 +7,3 @@ import { argv, proc } from './proc.js'; | ||
//@ts-ignore | ||
if (typeof repl !== 'undefined' || '_eval' in proc) { | ||
if (typeof repl !== 'undefined' || proc._forceRepl || '_eval' in proc) { | ||
return def; | ||
@@ -10,0 +10,0 @@ } |
@@ -9,6 +9,7 @@ /** | ||
if (isErrorLike(er)) { | ||
const { name, message, stack, error } = er; | ||
const { name, message, stack, error, code } = er; | ||
if (error && typeof error == 'string') | ||
return error; | ||
const nc = name && typeof name === 'string' ? `${name}: ` : ''; | ||
const ncCode = nc && typeof code === 'string' ? `${name} [${code}]: ` : ''; | ||
if (message && typeof message === 'string') | ||
@@ -20,3 +21,5 @@ return message; | ||
? lines[0].substring(nc.length) | ||
: lines[0]; | ||
: ncCode && lines[0].startsWith(ncCode) | ||
? lines[0].substring(ncCode.length) | ||
: lines[0]; | ||
} | ||
@@ -32,3 +35,5 @@ } | ||
typeof er.message !== 'undefined' || | ||
typeof er.stack !== 'undefined'); | ||
typeof er.stack !== 'undefined') && | ||
(er.code === undefined || | ||
typeof er.code === 'string'); | ||
//# sourceMappingURL=message-from-error.js.map |
@@ -304,32 +304,27 @@ /** | ||
}; | ||
// node 20 doesn't have requests in the same way as node 18 | ||
// we get different objects, handles vs requests, etc. | ||
// it's all very "internal machinery", version specific and unstable | ||
// there are tests to show that we can get SOMETHING in expected cases, | ||
// but it'll be completely differerent across node versions. | ||
/* c8 ignore start */ | ||
if (requests.length) { | ||
extra.requests = requests.map(r => { | ||
/* c8 ignore start */ | ||
if (!r || typeof r !== 'object') | ||
return r; | ||
/* c8 ignore stop */ | ||
const ret = { | ||
type: r.constructor.name, | ||
}; | ||
// most everything in node has a context these days | ||
/* c8 ignore start */ | ||
if (r.context) | ||
ret.context = r.context; | ||
/* c8 ignore stop */ | ||
return ret; | ||
}); | ||
} | ||
// Newer node versions don't have this as reliably. | ||
/* c8 ignore start */ | ||
if (handles.length) { | ||
extra.handles = handles.map(h => { | ||
/* c8 ignore start */ | ||
if (!h || typeof h !== 'object') | ||
return h; | ||
/* c8 ignore stop */ | ||
const ret = { | ||
type: h.constructor.name, | ||
}; | ||
// all of this is very internal-ish | ||
/* c8 ignore start */ | ||
if (h.msecs) | ||
@@ -343,6 +338,6 @@ ret.msecs = h.msecs; | ||
ret.connectionKey = h._connectionKey; | ||
/* c8 ignore stop */ | ||
return ret; | ||
}); | ||
} | ||
/* c8 ignore stop */ | ||
return extra; | ||
@@ -349,0 +344,0 @@ }; |
@@ -810,10 +810,4 @@ import * as stack from '@tapjs/stack'; | ||
} | ||
this.debug('MAIN pre', this.name); | ||
const end = () => { | ||
this.debug(' > implicit end for promise'); | ||
this.#promiseEnded = true; | ||
this.#end(IMPLICIT); | ||
done(); | ||
}; | ||
const done = (er) => { | ||
this.donePromise = undefined; | ||
if (er) | ||
@@ -848,5 +842,12 @@ this.threw(er); | ||
if (ret && ret.then) { | ||
this.donePromise = ret; | ||
ret.tapAbortPromise = done; | ||
ret.then(end, (er) => { | ||
this.donePromise = Object.assign(ret, { | ||
tapAbortPromise: done, | ||
}); | ||
ret.then(() => { | ||
this.debug(' > implicit end for promise'); | ||
this.#promiseEnded = true; | ||
if (!this.ended && !this.#awaitingEnd) | ||
this.#end(IMPLICIT); | ||
done(); | ||
}, (er) => { | ||
if (!er || typeof er !== 'object') { | ||
@@ -859,4 +860,5 @@ er = { error: er, at: null }; | ||
} | ||
else | ||
else { | ||
done(); | ||
} | ||
this.debug('MAIN post', this.name); | ||
@@ -1076,5 +1078,6 @@ } | ||
} | ||
if (er.stack && typeof er.stack === 'string') { | ||
if (!extra.stack && er.stack && typeof er.stack === 'string') { | ||
// trim off the first line if it looks like the standard | ||
// error `Name: message` line. | ||
/* c8 ignore start */ | ||
const f = `${er.name || 'Error'}: ${er.message}\n`; | ||
@@ -1084,2 +1087,3 @@ const st = er.stack.startsWith(f) | ||
: er.stack; | ||
/* c8 ignore stop */ | ||
const p = stack.parseStack(st); | ||
@@ -1107,2 +1111,5 @@ extra.at = p[0] || null; | ||
this.#process(); | ||
/* c8 ignore start */ | ||
this.donePromise?.tapAbortPromise?.(); | ||
/* c8 ignore stop */ | ||
} | ||
@@ -1174,4 +1181,3 @@ /** | ||
} | ||
if (this.donePromise && this.donePromise.tapAbortPromise) | ||
this.donePromise.tapAbortPromise(); | ||
this.donePromise?.tapAbortPromise?.(); | ||
for (let i = 0; i < this.queue.length; i++) { | ||
@@ -1178,0 +1184,0 @@ const p = this.queue[i]; |
{ | ||
"name": "@tapjs/core", | ||
"version": "0.0.0-20", | ||
"version": "0.0.0-21", | ||
"description": "pluggable core of node-tap", | ||
@@ -49,5 +49,5 @@ "author": "Isaac Z. Schlueter <i@izs.me> (https://blog.izs.me)", | ||
"dependencies": { | ||
"@tapjs/processinfo": "^2.5.6", | ||
"@tapjs/stack": "0.0.0-6", | ||
"@tapjs/test": "0.0.0-20", | ||
"@tapjs/processinfo": "^3.0.2", | ||
"@tapjs/stack": "0.0.0-7", | ||
"@tapjs/test": "0.0.0-21", | ||
"async-hook-domain": "^4.0.1", | ||
@@ -54,0 +54,0 @@ "is-actual-promise": "^1.0.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
819647
10194
+ Added@tapjs/processinfo@3.1.8(transitive)
+ Added@tapjs/stack@0.0.0-7(transitive)
+ Added@tapjs/test@0.0.0-21(transitive)
- Removed@tapjs/processinfo@2.5.6(transitive)
- Removed@tapjs/stack@0.0.0-6(transitive)
- Removed@tapjs/test@0.0.0-20(transitive)
Updated@tapjs/processinfo@^3.0.2
Updated@tapjs/stack@0.0.0-7
Updated@tapjs/test@0.0.0-21