@e-mc/module 0.7.8 → 0.7.10
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/index.js +46 -13
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -117,6 +117,25 @@ const VALUES = {
|
|
|
117
117
|
["logger.level"]: -1
|
|
118
118
|
};
|
|
119
119
|
const REGEXP_TORRENT = /^(?:magnet:\?xt=|(?:https?|s?ftp):\/\/[^/][^\n]*?\.(?:torrent|metalink|meta4)(?:\?[^\n]*)?$)/i;
|
|
120
|
+
const RESERVED_SHELL = [
|
|
121
|
+
'if',
|
|
122
|
+
'then',
|
|
123
|
+
'elif',
|
|
124
|
+
'else',
|
|
125
|
+
'fi',
|
|
126
|
+
'time',
|
|
127
|
+
'for',
|
|
128
|
+
'in',
|
|
129
|
+
'until',
|
|
130
|
+
'while',
|
|
131
|
+
'do',
|
|
132
|
+
'done',
|
|
133
|
+
'case',
|
|
134
|
+
'esac',
|
|
135
|
+
'coproc',
|
|
136
|
+
'select',
|
|
137
|
+
'function'
|
|
138
|
+
];
|
|
120
139
|
let LOG_NEWLINE = true;
|
|
121
140
|
let LOG_EMPTYLINE = false;
|
|
122
141
|
let TEMP_DIR = path.join(PROCESS_CWD, "tmp");
|
|
@@ -392,7 +411,7 @@ function addCacheItem(map, key, data) {
|
|
|
392
411
|
}
|
|
393
412
|
function checkFunction(value) {
|
|
394
413
|
if (typeof value === 'function') {
|
|
395
|
-
Object.defineProperty(value, "__cjs__", { value: true });
|
|
414
|
+
Object.defineProperty(value, "__cjs__", { value: true, writable: false, enumerable: false });
|
|
396
415
|
return value;
|
|
397
416
|
}
|
|
398
417
|
return null;
|
|
@@ -495,9 +514,16 @@ function applyLogId(options) {
|
|
|
495
514
|
}
|
|
496
515
|
return options;
|
|
497
516
|
}
|
|
498
|
-
function withinDir(value, base) {
|
|
517
|
+
function withinDir(value, base, override = false) {
|
|
499
518
|
value = path.normalize(value);
|
|
500
|
-
|
|
519
|
+
if (PLATFORM_WIN32) {
|
|
520
|
+
value = value.toLowerCase();
|
|
521
|
+
base = ensureDir(base.toLowerCase());
|
|
522
|
+
}
|
|
523
|
+
else {
|
|
524
|
+
base = ensureDir(base);
|
|
525
|
+
}
|
|
526
|
+
return value.startsWith(base) && (value !== base || override);
|
|
501
527
|
}
|
|
502
528
|
function formatPercent(value, precision) {
|
|
503
529
|
if (value <= 0) {
|
|
@@ -560,7 +586,7 @@ class Module extends EventEmitter {
|
|
|
560
586
|
this[_f] = new AbortController();
|
|
561
587
|
this[_g] = null;
|
|
562
588
|
}
|
|
563
|
-
static get VERSION() { return "0.7.
|
|
589
|
+
static get VERSION() { return "0.7.10"; }
|
|
564
590
|
static get LOG_TYPE() { return types_1.LOG_TYPE; }
|
|
565
591
|
static get STATUS_TYPE() { return types_1.STATUS_TYPE; }
|
|
566
592
|
static get MAX_TIMEOUT() { return 2147483647; }
|
|
@@ -848,10 +874,14 @@ class Module extends EventEmitter {
|
|
|
848
874
|
({ color: hintColor, bgColor: hintBgColor } = formatHint);
|
|
849
875
|
hintBold !== null && hintBold !== void 0 ? hintBold : (hintBold = formatHint.bold);
|
|
850
876
|
}
|
|
851
|
-
value = getValue() + (coloring ? chalk.blackBright('[') + formatColumn(truncateEnd(hint, hintWidth), hintColor, hintBgColor, hintBold) + chalk.blackBright(']') : `[${truncateEnd(hint, hintWidth)}]`);
|
|
852
|
-
}
|
|
853
|
-
else if (title) {
|
|
854
877
|
value = getValue();
|
|
878
|
+
hint = coloring ? chalk.blackBright('[') + formatColumn(truncateEnd(hint, hintWidth), hintColor, hintBgColor, hintBold) + chalk.blackBright(']') : `[${truncateEnd(hint, hintWidth)}]`;
|
|
879
|
+
}
|
|
880
|
+
else {
|
|
881
|
+
if (title) {
|
|
882
|
+
value = getValue();
|
|
883
|
+
}
|
|
884
|
+
hint = '';
|
|
855
885
|
}
|
|
856
886
|
const unit = options.messageUnit ? type & 256 ? options.messageUnit.padStart(options.messageUnitMinWidth || 0) : options.messageUnit : '';
|
|
857
887
|
const getMessage = (m, u) => type & 256 && messageUnitIndent === undefined ? (u + m).trimEnd() : u ? (m + (messageUnitIndent === undefined ? ' ' : '') + u).trimStart() : m;
|
|
@@ -896,19 +926,19 @@ class Module extends EventEmitter {
|
|
|
896
926
|
}
|
|
897
927
|
}
|
|
898
928
|
else {
|
|
899
|
-
if (!i) {
|
|
929
|
+
if (!i && !hint) {
|
|
900
930
|
v = v.trim();
|
|
901
931
|
}
|
|
902
932
|
m = '';
|
|
903
933
|
}
|
|
904
|
-
output = (titleIndent !== -1 ? title : title ? formatColumn(title, titleColor || 'green', titleBgColor, (_k = (options.titleBold || formatTitle.bold)) !== null && _k !== void 0 ? _k : false) + chalk.blackBright(':') + ' ' : '') + formatColumn(v, valueColor, valueBgColor, valueBold) + (i ? i : ' ') + m;
|
|
934
|
+
output = (titleIndent !== -1 ? title : title ? formatColumn(title, titleColor || 'green', titleBgColor, (_k = (options.titleBold || formatTitle.bold)) !== null && _k !== void 0 ? _k : false) + chalk.blackBright(':') + ' ' : '') + formatColumn(v, valueColor, valueBgColor, valueBold) + hint + (i ? i : ' ') + m;
|
|
905
935
|
}
|
|
906
936
|
catch {
|
|
907
937
|
}
|
|
908
938
|
}
|
|
909
939
|
if (!output) {
|
|
910
|
-
const m = truncateStart(this.asString(message), (_l = options.messageWidth) !== null && _l !== void 0 ? _l : format.message.width);
|
|
911
|
-
output = (titleIndent !== -1 ? title : title ? title + ': ' : '') + value + (id ? id : ' ') + (m && SETTINGS.message !== false ? (error ? '{' : '(') + getMessage(m, unit) + (error ? '}' : ')') : '');
|
|
940
|
+
const m = truncateStart(stripansi(this.asString(message)), (_l = options.messageWidth) !== null && _l !== void 0 ? _l : format.message.width);
|
|
941
|
+
output = (titleIndent !== -1 ? title : title ? title + ': ' : '') + stripansi(value) + stripansi(hint) + (id ? id : ' ') + (m && SETTINGS.message !== false ? (error ? '{' : '(') + getMessage(m, unit) + (error ? '}' : ')') : '');
|
|
912
942
|
}
|
|
913
943
|
if (broadcastId) {
|
|
914
944
|
if (BROADCAST_OUT) {
|
|
@@ -1922,6 +1952,9 @@ class Module extends EventEmitter {
|
|
|
1922
1952
|
value = "'" + value.replace(/'/g, "'\\''") + "'";
|
|
1923
1953
|
}
|
|
1924
1954
|
}
|
|
1955
|
+
else if (RESERVED_SHELL.includes(value)) {
|
|
1956
|
+
value = "'" + value + "'";
|
|
1957
|
+
}
|
|
1925
1958
|
}
|
|
1926
1959
|
}
|
|
1927
1960
|
else if (opt) {
|
|
@@ -2346,7 +2379,7 @@ class Module extends EventEmitter {
|
|
|
2346
2379
|
if (permission && (Module.isFile(uri, 'unc') ? permission.hasUNCRead(path.normalize(uri)) || ownPermissionOnly && !permission.getUNCRead() : path.isAbsolute(uri = path.resolve(uri)) && (permission.hasDiskRead(uri) || ownPermissionOnly && !permission.getDiskRead()))) {
|
|
2347
2380
|
return true;
|
|
2348
2381
|
}
|
|
2349
|
-
return VALUES["permission.home_read"] && withinDir(uri, OS_HOMEDIR);
|
|
2382
|
+
return VALUES["permission.home_read"] && withinDir(uri, OS_HOMEDIR, true);
|
|
2350
2383
|
}
|
|
2351
2384
|
canWrite(uri, options) {
|
|
2352
2385
|
let permission = this.permission, ownPermissionOnly = false;
|
|
@@ -2367,7 +2400,7 @@ class Module extends EventEmitter {
|
|
|
2367
2400
|
if (permission && (Module.isFile(uri, 'unc') ? permission.hasUNCWrite(path.normalize(uri)) || ownPermissionOnly && !permission.getUNCWrite() : path.isAbsolute(uri = path.resolve(uri)) && (permission.hasDiskWrite(uri) || ownPermissionOnly && !permission.getDiskWrite()))) {
|
|
2368
2401
|
return true;
|
|
2369
2402
|
}
|
|
2370
|
-
return VALUES["temp.write"] && withinDir(uri, TEMP_DIR) || VALUES["permission.home_write"] && withinDir(uri, OS_HOMEDIR);
|
|
2403
|
+
return VALUES["temp.write"] && withinDir(uri, TEMP_DIR, true) || VALUES["permission.home_write"] && withinDir(uri, OS_HOMEDIR, true);
|
|
2371
2404
|
}
|
|
2372
2405
|
readFile(src, options = {}, callback) {
|
|
2373
2406
|
let promises, outSrc;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-mc/module",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.10",
|
|
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.7.
|
|
23
|
+
"@e-mc/types": "0.7.10",
|
|
24
24
|
"abort-controller": "^3.0.0",
|
|
25
25
|
"chalk": "4.1.2",
|
|
26
26
|
"event-target-shim": "^5.0.1",
|