@e-mc/module 0.6.5 → 0.6.7
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.6.
|
|
589
|
+
static get VERSION() { return "0.6.7"; }
|
|
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) {
|
|
@@ -1891,6 +1921,9 @@ class Module extends EventEmitter {
|
|
|
1891
1921
|
value = "'" + value.replace(/'/g, "'\\''") + "'";
|
|
1892
1922
|
}
|
|
1893
1923
|
}
|
|
1924
|
+
else if (RESERVED_SHELL.includes(value)) {
|
|
1925
|
+
value = "'" + value + "'";
|
|
1926
|
+
}
|
|
1894
1927
|
}
|
|
1895
1928
|
}
|
|
1896
1929
|
else if (opt) {
|
|
@@ -2314,7 +2347,7 @@ class Module extends EventEmitter {
|
|
|
2314
2347
|
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()))) {
|
|
2315
2348
|
return true;
|
|
2316
2349
|
}
|
|
2317
|
-
return VALUES["permission.home_read"] && withinDir(uri, OS_HOMEDIR);
|
|
2350
|
+
return VALUES["permission.home_read"] && withinDir(uri, OS_HOMEDIR, true);
|
|
2318
2351
|
}
|
|
2319
2352
|
canWrite(uri, options) {
|
|
2320
2353
|
let permission = this.permission, ownPermissionOnly = false;
|
|
@@ -2335,7 +2368,7 @@ class Module extends EventEmitter {
|
|
|
2335
2368
|
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()))) {
|
|
2336
2369
|
return true;
|
|
2337
2370
|
}
|
|
2338
|
-
return VALUES["temp.write"] && withinDir(uri, TEMP_DIR) || VALUES["permission.home_write"] && withinDir(uri, OS_HOMEDIR);
|
|
2371
|
+
return VALUES["temp.write"] && withinDir(uri, TEMP_DIR, true) || VALUES["permission.home_write"] && withinDir(uri, OS_HOMEDIR, true);
|
|
2339
2372
|
}
|
|
2340
2373
|
readFile(src, options = {}, callback) {
|
|
2341
2374
|
let promises, outSrc;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-mc/module",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.7",
|
|
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.6.
|
|
23
|
+
"@e-mc/types": "0.6.7",
|
|
24
24
|
"abort-controller": "^3.0.0",
|
|
25
25
|
"chalk": "4.1.2",
|
|
26
26
|
"event-target-shim": "^5.0.1",
|