@e-mc/module 0.8.24 → 0.8.25
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 +5 -5
- package/index.js +29 -41
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
## Interface
|
|
11
11
|
|
|
12
|
-
- https://www.unpkg.com/@e-mc/types@0.8.
|
|
12
|
+
- https://www.unpkg.com/@e-mc/types@0.8.25/lib/index.d.ts
|
|
13
13
|
|
|
14
14
|
```typescript
|
|
15
15
|
import type { LogStatus } from "./squared";
|
|
@@ -231,10 +231,10 @@ interface ModuleConstructor {
|
|
|
231
231
|
|
|
232
232
|
## References
|
|
233
233
|
|
|
234
|
-
- https://www.unpkg.com/@e-mc/types@0.8.
|
|
235
|
-
- https://www.unpkg.com/@e-mc/types@0.8.
|
|
236
|
-
- https://www.unpkg.com/@e-mc/types@0.8.
|
|
237
|
-
- https://www.unpkg.com/@e-mc/types@0.8.
|
|
234
|
+
- https://www.unpkg.com/@e-mc/types@0.8.25/lib/core.d.ts
|
|
235
|
+
- https://www.unpkg.com/@e-mc/types@0.8.25/lib/logger.d.ts
|
|
236
|
+
- https://www.unpkg.com/@e-mc/types@0.8.25/lib/module.d.ts
|
|
237
|
+
- https://www.unpkg.com/@e-mc/types@0.8.25/lib/node.d.ts
|
|
238
238
|
|
|
239
239
|
## LICENSE
|
|
240
240
|
|
package/index.js
CHANGED
|
@@ -680,6 +680,7 @@ function formatPercent(value, precision) {
|
|
|
680
680
|
value *= 100;
|
|
681
681
|
return value.toPrecision(value < 1 ? 2 : precision) + '%';
|
|
682
682
|
}
|
|
683
|
+
const isErrorNo = (value) => value instanceof Error && (0, types_1.isString)(value.code);
|
|
683
684
|
const hideAbort = (err) => err.name === 'AbortError' && SETTINGS.abort === false;
|
|
684
685
|
const asFile = (value) => typeof value === 'string' ? PLATFORM_WIN32 ? value.trim() : value : value instanceof URL && value.protocol === 'file:' ? url.fileURLToPath(value) : '';
|
|
685
686
|
const wrapQuote = (value) => '"' + value.replace(/"/g, '\\"') + '"';
|
|
@@ -716,7 +717,7 @@ class Module extends EventEmitter {
|
|
|
716
717
|
this[_f] = new AbortController();
|
|
717
718
|
this[_g] = null;
|
|
718
719
|
}
|
|
719
|
-
static get VERSION() { return "0.8.
|
|
720
|
+
static get VERSION() { return "0.8.25"; }
|
|
720
721
|
static get LOG_TYPE() { return types_1.LOG_TYPE; }
|
|
721
722
|
static get STATUS_TYPE() { return types_1.STATUS_TYPE; }
|
|
722
723
|
static get MAX_TIMEOUT() { return 2147483647; }
|
|
@@ -1407,11 +1408,7 @@ class Module extends EventEmitter {
|
|
|
1407
1408
|
}
|
|
1408
1409
|
}
|
|
1409
1410
|
static isErrorCode(err, ...code) {
|
|
1410
|
-
|
|
1411
|
-
const value = err.code;
|
|
1412
|
-
return typeof value === 'string' && code.includes(value);
|
|
1413
|
-
}
|
|
1414
|
-
return false;
|
|
1411
|
+
return isErrorNo(err) && code.includes(err.code);
|
|
1415
1412
|
}
|
|
1416
1413
|
static resolveFile(value) {
|
|
1417
1414
|
if (isFileURL(value = value instanceof URL ? value.toString() : value)) {
|
|
@@ -3197,9 +3194,6 @@ class Module extends EventEmitter {
|
|
|
3197
3194
|
else if (result === false) {
|
|
3198
3195
|
return;
|
|
3199
3196
|
}
|
|
3200
|
-
if (options.passThrough) {
|
|
3201
|
-
message = null;
|
|
3202
|
-
}
|
|
3203
3197
|
const args = [(type | 512), title, value, message, applyStyle(options, Module.LOG_STYLE_FAIL)];
|
|
3204
3198
|
applyLogId.call(this, options);
|
|
3205
3199
|
if (options.queue !== false && !options.passThrough && !this._logFlushed) {
|
|
@@ -3329,11 +3323,11 @@ class Module extends EventEmitter {
|
|
|
3329
3323
|
options = value;
|
|
3330
3324
|
value = undefined;
|
|
3331
3325
|
}
|
|
3332
|
-
if (
|
|
3326
|
+
if (name && isErrorNo(err) && err.code.endsWith(types_1.ERR_CODE.MODULE_NOT_FOUND)) {
|
|
3333
3327
|
if (typeof options === 'number') {
|
|
3334
3328
|
options = undefined;
|
|
3335
3329
|
}
|
|
3336
|
-
this.writeFail("
|
|
3330
|
+
this.writeFail("Package not found", err, { ...options, type: types_1.LOG_TYPE.SYSTEM, code: err.code, exec: { command: 'npm', args: ['i', name] } });
|
|
3337
3331
|
return true;
|
|
3338
3332
|
}
|
|
3339
3333
|
if (value) {
|
|
@@ -3342,38 +3336,32 @@ class Module extends EventEmitter {
|
|
|
3342
3336
|
return false;
|
|
3343
3337
|
}
|
|
3344
3338
|
checkFail(message, options) {
|
|
3345
|
-
|
|
3346
|
-
if (code && message
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
options.passThrough = false;
|
|
3368
|
-
message = null;
|
|
3369
|
-
}
|
|
3370
|
-
return { type, value: ["Install required?", command], message };
|
|
3371
|
-
}
|
|
3372
|
-
delete options.exec;
|
|
3373
|
-
}
|
|
3374
|
-
break;
|
|
3339
|
+
let { code, exec } = options;
|
|
3340
|
+
if (!code && isErrorNo(message)) {
|
|
3341
|
+
code = message.code;
|
|
3342
|
+
}
|
|
3343
|
+
if (exec && (code === null || code === void 0 ? void 0 : code.endsWith(types_1.ERR_CODE.MODULE_NOT_FOUND))) {
|
|
3344
|
+
if (!this.aborted) {
|
|
3345
|
+
const command = exec.command + (exec.args ? ' ' + exec.args.join(' ') : '');
|
|
3346
|
+
const target = this.host || this;
|
|
3347
|
+
let session = CACHE_EXEC.get(target);
|
|
3348
|
+
if (!session) {
|
|
3349
|
+
CACHE_EXEC.set(target, session = []);
|
|
3350
|
+
}
|
|
3351
|
+
if (session.includes(command)) {
|
|
3352
|
+
return false;
|
|
3353
|
+
}
|
|
3354
|
+
session.push(command);
|
|
3355
|
+
let type = options.type || 0;
|
|
3356
|
+
type |= 4096;
|
|
3357
|
+
type &= ~1;
|
|
3358
|
+
if (options.passThrough) {
|
|
3359
|
+
options.passThrough = false;
|
|
3360
|
+
message = null;
|
|
3375
3361
|
}
|
|
3362
|
+
return { type, value: ["Install required?", command], message };
|
|
3376
3363
|
}
|
|
3364
|
+
delete options.exec;
|
|
3377
3365
|
}
|
|
3378
3366
|
}
|
|
3379
3367
|
writeLog(type, value, timeStamp, duration) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-mc/module",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.25",
|
|
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": "MIT",
|
|
21
21
|
"homepage": "https://github.com/anpham6/e-mc#readme",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@e-mc/types": "0.8.
|
|
23
|
+
"@e-mc/types": "0.8.25",
|
|
24
24
|
"abort-controller": "^3.0.0",
|
|
25
25
|
"chalk": "4.1.2",
|
|
26
26
|
"event-target-shim": "^5.0.1",
|