@e-mc/module 0.5.8 → 0.5.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/README.md +0 -2
- package/index.js +46 -13
- package/package.json +2 -2
package/README.md
CHANGED
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.5.
|
|
589
|
+
static get VERSION() { return "0.5.9"; }
|
|
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) {
|
|
@@ -1889,6 +1919,9 @@ class Module extends EventEmitter {
|
|
|
1889
1919
|
value = "'" + value.replace(/'/g, "'\\''") + "'";
|
|
1890
1920
|
}
|
|
1891
1921
|
}
|
|
1922
|
+
else if (RESERVED_SHELL.includes(value)) {
|
|
1923
|
+
value = "'" + value + "'";
|
|
1924
|
+
}
|
|
1892
1925
|
}
|
|
1893
1926
|
}
|
|
1894
1927
|
else if (opt) {
|
|
@@ -2312,7 +2345,7 @@ class Module extends EventEmitter {
|
|
|
2312
2345
|
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()))) {
|
|
2313
2346
|
return true;
|
|
2314
2347
|
}
|
|
2315
|
-
return VALUES["permission.home_read"] && withinDir(uri, OS_HOMEDIR);
|
|
2348
|
+
return VALUES["permission.home_read"] && withinDir(uri, OS_HOMEDIR, true);
|
|
2316
2349
|
}
|
|
2317
2350
|
canWrite(uri, options) {
|
|
2318
2351
|
let permission = this.permission, ownPermissionOnly = false;
|
|
@@ -2333,7 +2366,7 @@ class Module extends EventEmitter {
|
|
|
2333
2366
|
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()))) {
|
|
2334
2367
|
return true;
|
|
2335
2368
|
}
|
|
2336
|
-
return VALUES["temp.write"] && withinDir(uri, TEMP_DIR) || VALUES["permission.home_write"] && withinDir(uri, OS_HOMEDIR);
|
|
2369
|
+
return VALUES["temp.write"] && withinDir(uri, TEMP_DIR, true) || VALUES["permission.home_write"] && withinDir(uri, OS_HOMEDIR, true);
|
|
2337
2370
|
}
|
|
2338
2371
|
readFile(src, options = {}, callback) {
|
|
2339
2372
|
let promises, outSrc;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-mc/module",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.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.5.
|
|
23
|
+
"@e-mc/types": "0.5.10",
|
|
24
24
|
"abort-controller": "^3.0.0",
|
|
25
25
|
"chalk": "4.1.2",
|
|
26
26
|
"event-target-shim": "^5.0.1",
|