@e-mc/module 0.10.10 → 0.10.11
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/README.md +6 -6
- package/index.js +36 -42
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
## Interface
|
|
11
11
|
|
|
12
|
-
* [View Source](https://www.unpkg.com/@e-mc/types@0.10.
|
|
12
|
+
* [View Source](https://www.unpkg.com/@e-mc/types@0.10.11/lib/index.d.ts)
|
|
13
13
|
|
|
14
14
|
```typescript
|
|
15
15
|
import type { LogStatus } from "./squared";
|
|
@@ -407,11 +407,11 @@ interface LoggerModule {
|
|
|
407
407
|
|
|
408
408
|
## References
|
|
409
409
|
|
|
410
|
-
- https://www.unpkg.com/@e-mc/types@0.10.
|
|
411
|
-
- https://www.unpkg.com/@e-mc/types@0.10.
|
|
412
|
-
- https://www.unpkg.com/@e-mc/types@0.10.
|
|
413
|
-
- https://www.unpkg.com/@e-mc/types@0.10.
|
|
414
|
-
- https://www.unpkg.com/@e-mc/types@0.10.
|
|
410
|
+
- https://www.unpkg.com/@e-mc/types@0.10.11/lib/core.d.ts
|
|
411
|
+
- https://www.unpkg.com/@e-mc/types@0.10.11/lib/logger.d.ts
|
|
412
|
+
- https://www.unpkg.com/@e-mc/types@0.10.11/lib/module.d.ts
|
|
413
|
+
- https://www.unpkg.com/@e-mc/types@0.10.11/lib/node.d.ts
|
|
414
|
+
- https://www.unpkg.com/@e-mc/types@0.10.11/lib/settings.d.ts
|
|
415
415
|
|
|
416
416
|
* https://www.npmjs.com/package/@types/node
|
|
417
417
|
|
package/index.js
CHANGED
|
@@ -917,6 +917,7 @@ function truncateStart(value, length = LOG_MIN_WIDTH, style = false) {
|
|
|
917
917
|
function truncateEnd(value, length) {
|
|
918
918
|
return (REGEXP_ANSIESCAPE.test(value) ? stripansi(value) : value).length > length ? '...' + value.substring(value.length - length + 3) : value;
|
|
919
919
|
}
|
|
920
|
+
const isErrorNo = (value) => value instanceof Error && (0, types_1.isString)(value.code);
|
|
920
921
|
const formatLogMessage = (type, message, unit, ident) => !ident && (type & 256) ? (unit + LOG_DIVIDER + message).trimEnd() : unit ? (type & 256) && ident ? unit + LOG_DIVIDER + message : (message + (ident ? '' : ' ') + unit).trimStart() : message;
|
|
921
922
|
const hideAbort = (err) => err.name === 'AbortError' && SETTINGS.abort === false;
|
|
922
923
|
const asFile = (value) => typeof value === 'string' ? PLATFORM_WIN32 ? value.trim() : value : value instanceof URL && value.protocol === 'file:' ? (0, url_1.fileURLToPath)(value) : '';
|
|
@@ -959,7 +960,7 @@ class Module extends EventEmitter {
|
|
|
959
960
|
this[_g] = null;
|
|
960
961
|
}
|
|
961
962
|
static get VERSION() {
|
|
962
|
-
return "0.10.
|
|
963
|
+
return "0.10.11";
|
|
963
964
|
}
|
|
964
965
|
static get LOG_TYPE() {
|
|
965
966
|
return types_1.LOG_TYPE;
|
|
@@ -1640,11 +1641,7 @@ class Module extends EventEmitter {
|
|
|
1640
1641
|
}
|
|
1641
1642
|
}
|
|
1642
1643
|
static isErrorCode(err, ...code) {
|
|
1643
|
-
|
|
1644
|
-
const value = err.code;
|
|
1645
|
-
return typeof value === 'string' && code.includes(value);
|
|
1646
|
-
}
|
|
1647
|
-
return false;
|
|
1644
|
+
return isErrorNo(err) && code.includes(err.code);
|
|
1648
1645
|
}
|
|
1649
1646
|
static resolveFile(value) {
|
|
1650
1647
|
if (isFileURL(value = value instanceof URL ? value.toString() : value)) {
|
|
@@ -3475,10 +3472,13 @@ class Module extends EventEmitter {
|
|
|
3475
3472
|
else if (result === false) {
|
|
3476
3473
|
return;
|
|
3477
3474
|
}
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3475
|
+
const args = [
|
|
3476
|
+
(type | 512),
|
|
3477
|
+
title,
|
|
3478
|
+
value,
|
|
3479
|
+
message,
|
|
3480
|
+
applyStyle(options, Module.LOG_STYLE_FAIL)
|
|
3481
|
+
];
|
|
3482
3482
|
applySessionId(this, options);
|
|
3483
3483
|
if (options.queue !== false && !options.passThrough && !this._logFlushed) {
|
|
3484
3484
|
if (VALUES["error.out"]) {
|
|
@@ -3607,11 +3607,11 @@ class Module extends EventEmitter {
|
|
|
3607
3607
|
options = value;
|
|
3608
3608
|
value = undefined;
|
|
3609
3609
|
}
|
|
3610
|
-
if (
|
|
3610
|
+
if (name && isErrorNo(err) && err.code.endsWith(types_1.ERR_CODE.MODULE_NOT_FOUND)) {
|
|
3611
3611
|
if (typeof options === 'number') {
|
|
3612
3612
|
options = undefined;
|
|
3613
3613
|
}
|
|
3614
|
-
this.writeFail("
|
|
3614
|
+
this.writeFail("Package not found", err, { ...options, type: types_1.LOG_TYPE.SYSTEM, code: err.code, exec: { command: 'npm', args: ['i', name] } });
|
|
3615
3615
|
return true;
|
|
3616
3616
|
}
|
|
3617
3617
|
if (value) {
|
|
@@ -3620,38 +3620,32 @@ class Module extends EventEmitter {
|
|
|
3620
3620
|
return false;
|
|
3621
3621
|
}
|
|
3622
3622
|
checkFail(message, options) {
|
|
3623
|
-
|
|
3624
|
-
if (code && message
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
options.passThrough = false;
|
|
3646
|
-
message = null;
|
|
3647
|
-
}
|
|
3648
|
-
return { type, value: ["Install required?", command], message };
|
|
3649
|
-
}
|
|
3650
|
-
delete options.exec;
|
|
3651
|
-
}
|
|
3652
|
-
break;
|
|
3623
|
+
let { code, exec } = options;
|
|
3624
|
+
if (!code && isErrorNo(message)) {
|
|
3625
|
+
code = message.code;
|
|
3626
|
+
}
|
|
3627
|
+
if (exec && code?.endsWith(types_1.ERR_CODE.MODULE_NOT_FOUND)) {
|
|
3628
|
+
if (!this.aborted) {
|
|
3629
|
+
const command = exec.command + (exec.args ? ' ' + exec.args.join(' ') : '');
|
|
3630
|
+
const target = this.host || this;
|
|
3631
|
+
let session = CACHE_EXEC.get(target);
|
|
3632
|
+
if (!session) {
|
|
3633
|
+
CACHE_EXEC.set(target, session = []);
|
|
3634
|
+
}
|
|
3635
|
+
if (session.includes(command)) {
|
|
3636
|
+
return false;
|
|
3637
|
+
}
|
|
3638
|
+
session.push(command);
|
|
3639
|
+
let type = options.type || 0;
|
|
3640
|
+
type |= 4096;
|
|
3641
|
+
type &= ~1;
|
|
3642
|
+
if (options.passThrough) {
|
|
3643
|
+
options.passThrough = false;
|
|
3644
|
+
message = null;
|
|
3653
3645
|
}
|
|
3646
|
+
return { type, value: ["Install required?", command], message };
|
|
3654
3647
|
}
|
|
3648
|
+
delete options.exec;
|
|
3655
3649
|
}
|
|
3656
3650
|
}
|
|
3657
3651
|
writeLog(type, value, timeStamp, duration) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-mc/module",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.11",
|
|
4
4
|
"description": "Module base class for E-mc.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"license": "BSD-3-Clause",
|
|
21
21
|
"homepage": "https://github.com/anpham6/e-mc#readme",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@e-mc/types": "0.10.
|
|
23
|
+
"@e-mc/types": "0.10.11",
|
|
24
24
|
"chalk": "4.1.2",
|
|
25
25
|
"file-type": "^18.7.0",
|
|
26
26
|
"js-yaml": "^4.1.0",
|