@e-mc/module 0.9.9 → 0.10.1
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 +30 -18
- package/index.js +733 -524
- package/lib-v4.js +14 -14
- package/package.json +3 -3
package/index.js
CHANGED
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
3
3
|
const path = require("path");
|
|
4
4
|
const fs = require("fs");
|
|
5
|
+
const stream = require("stream");
|
|
5
6
|
const os = require("os");
|
|
6
7
|
const crypto = require("crypto");
|
|
7
|
-
const url = require("url");
|
|
8
|
-
const filetype = require("file-type");
|
|
9
8
|
const mime = require("mime-types");
|
|
10
9
|
const pm = require("picomatch");
|
|
11
10
|
const chalk = require("chalk");
|
|
12
11
|
const yaml = require("js-yaml");
|
|
13
12
|
const stripansi = require("strip-ansi");
|
|
14
13
|
const EventEmitter = require("events");
|
|
14
|
+
const url_1 = require("url");
|
|
15
15
|
const types_1 = require("@e-mc/types");
|
|
16
16
|
const kSessionId = Symbol('sessionId');
|
|
17
17
|
const kBroadcastId = Symbol('broadcastId');
|
|
@@ -26,14 +26,20 @@ const PLATFORM_WIN32 = process.platform === 'win32';
|
|
|
26
26
|
const OS_HOMEDIR = os.homedir();
|
|
27
27
|
const MEM_TOTAL = os.totalmem();
|
|
28
28
|
const CPU_CORETOTAL = os.cpus().length;
|
|
29
|
-
const [VER_MAJOR, VER_MINOR, VER_PATCH] = process.version.substring(1).split('.').map(value => +value);
|
|
30
29
|
const CACHE_READTEXT = new Map();
|
|
31
30
|
const CACHE_READBUFFER = new Map();
|
|
32
31
|
const CACHE_READCJS = new Map();
|
|
33
32
|
let CACHE_EXEC = new WeakMap();
|
|
34
33
|
let CACHE_CPU = new WeakMap();
|
|
35
34
|
let CACHE_CPUHOST = new WeakMap();
|
|
36
|
-
|
|
35
|
+
const SETTINGS_PROCESS = {
|
|
36
|
+
cpu: true,
|
|
37
|
+
cpu_bar: true,
|
|
38
|
+
cpu_bar_color: ['bgBlue', 'bgYellow', 'bgRed'],
|
|
39
|
+
cpu_single_core: true,
|
|
40
|
+
mem: true,
|
|
41
|
+
mem_format: '%'
|
|
42
|
+
};
|
|
37
43
|
const SETTINGS = {
|
|
38
44
|
enabled: true,
|
|
39
45
|
production: undefined,
|
|
@@ -41,7 +47,8 @@ const SETTINGS = {
|
|
|
41
47
|
title: {
|
|
42
48
|
width: 6,
|
|
43
49
|
justify: 'right',
|
|
44
|
-
as: {}
|
|
50
|
+
as: {},
|
|
51
|
+
braces: '|'
|
|
45
52
|
},
|
|
46
53
|
value: {
|
|
47
54
|
width: 71,
|
|
@@ -50,15 +57,24 @@ const SETTINGS = {
|
|
|
50
57
|
hint: {
|
|
51
58
|
width: 32,
|
|
52
59
|
unit: 'auto',
|
|
53
|
-
as: {}
|
|
60
|
+
as: {},
|
|
61
|
+
braces: ['', ' |']
|
|
54
62
|
},
|
|
55
63
|
meter: {
|
|
56
64
|
width: Infinity,
|
|
57
65
|
bgColor: 'bgCyan',
|
|
58
66
|
bgAltColor: 'bgYellow'
|
|
59
67
|
},
|
|
68
|
+
error: {
|
|
69
|
+
color: 'blackBright',
|
|
70
|
+
altColor: 'redBright',
|
|
71
|
+
bgColor: 'bgWhite',
|
|
72
|
+
braces: ['{', '}']
|
|
73
|
+
},
|
|
60
74
|
session_id: {},
|
|
61
|
-
message: {
|
|
75
|
+
message: {
|
|
76
|
+
braces: ['| ', '']
|
|
77
|
+
}
|
|
62
78
|
},
|
|
63
79
|
meter: {
|
|
64
80
|
http: 100,
|
|
@@ -80,13 +96,7 @@ const SETTINGS = {
|
|
|
80
96
|
unknown: true,
|
|
81
97
|
system: true,
|
|
82
98
|
node: true,
|
|
83
|
-
process: {
|
|
84
|
-
cpu: true,
|
|
85
|
-
cpu_bar: true,
|
|
86
|
-
cpu_single_core: true,
|
|
87
|
-
mem: true,
|
|
88
|
-
mem_format: '%'
|
|
89
|
-
},
|
|
99
|
+
process: { ...SETTINGS_PROCESS },
|
|
90
100
|
image: true,
|
|
91
101
|
compress: true,
|
|
92
102
|
watch: true,
|
|
@@ -128,7 +138,14 @@ const MEMORY_CACHE_DISK = {
|
|
|
128
138
|
include: null,
|
|
129
139
|
exclude: null
|
|
130
140
|
};
|
|
141
|
+
const SUPPORTED_CANPARSE = (0, types_1.supported)(19, 9) || (0, types_1.supported)(18, 17, 0, true);
|
|
131
142
|
const REGEXP_TORRENT = /^(?:magnet:\?xt=|(?:https?|s?ftp):\/\/[^/][^\n]*?\.(?:torrent|metalink|meta4)(?:\?[^\n]*)?$)/i;
|
|
143
|
+
const REGEXP_PROTOCOL = /^([a-z][a-z\d+-.]*):\/\/[^@:[\]\\^<>|\s]/i;
|
|
144
|
+
const REGEXP_CLIESCAPE = /[^\w%+-./:=@]/g;
|
|
145
|
+
const REGEXP_CLIOPTION = /^(-[^\s=]+|--[^-\s=][^\s=]*)(=)?\s*(.*)$/;
|
|
146
|
+
const REGEXP_ANSIESCAPE = /[\u001B\u009B]/;
|
|
147
|
+
const LOG_CPUBARCOLOR = SETTINGS.process.cpu_bar_color;
|
|
148
|
+
const LOG_DIVIDER = chalk.blackBright('|');
|
|
132
149
|
const RESERVED_SHELL = [
|
|
133
150
|
'if',
|
|
134
151
|
'then',
|
|
@@ -150,9 +167,11 @@ const RESERVED_SHELL = [
|
|
|
150
167
|
];
|
|
151
168
|
let LOG_NEWLINE = true;
|
|
152
169
|
let LOG_EMPTYLINE = false;
|
|
170
|
+
let LOG_MIN_WIDTH = 0;
|
|
153
171
|
let TEMP_DIR = path.join(PROCESS_CWD, "tmp");
|
|
154
172
|
let PNPM_VER;
|
|
155
173
|
let YARN_VER;
|
|
174
|
+
let FILETYPE_ESM = null;
|
|
156
175
|
function parseYaml(pathname) {
|
|
157
176
|
return yaml.load(fs.readFileSync(pathname, 'utf-8'));
|
|
158
177
|
}
|
|
@@ -170,20 +189,8 @@ function setPnpmVer() {
|
|
|
170
189
|
if (config.nodeLinker === 'pnp') {
|
|
171
190
|
return false;
|
|
172
191
|
}
|
|
173
|
-
const addPackage = (value) => {
|
|
174
|
-
let index = value.indexOf('(');
|
|
175
|
-
if (index !== -1) {
|
|
176
|
-
value = value.substring(0, index);
|
|
177
|
-
}
|
|
178
|
-
index = value.lastIndexOf(value.indexOf('@', 2) !== -1 ? '@' : '/');
|
|
179
|
-
const name = value.substring(1, index);
|
|
180
|
-
const version = value.substring(index + 1);
|
|
181
|
-
if (!items.find(item => item[0] === name && item[1] === version)) {
|
|
182
|
-
items.push([name, version]);
|
|
183
|
-
}
|
|
184
|
-
};
|
|
185
192
|
for (const name in config.hoistedDependencies) {
|
|
186
|
-
|
|
193
|
+
addPnpmPackage(items, name);
|
|
187
194
|
}
|
|
188
195
|
if (!path.isAbsolute(baseDir = config.virtualStoreDir)) {
|
|
189
196
|
baseDir = path.resolve('node_modules', baseDir);
|
|
@@ -193,19 +200,31 @@ function setPnpmVer() {
|
|
|
193
200
|
}
|
|
194
201
|
else if ((0, types_1.isPlainObject)(config = parseYaml(pathname))) {
|
|
195
202
|
for (const name in config.packages) {
|
|
196
|
-
|
|
203
|
+
addPnpmPackage(items, name);
|
|
197
204
|
}
|
|
198
205
|
}
|
|
199
206
|
}
|
|
200
207
|
}
|
|
201
208
|
catch {
|
|
202
209
|
}
|
|
203
|
-
if (items.length) {
|
|
210
|
+
if (items.length > 0) {
|
|
204
211
|
PNPM_VER = { baseDir, items };
|
|
205
212
|
}
|
|
206
213
|
}
|
|
207
214
|
return PNPM_VER;
|
|
208
215
|
}
|
|
216
|
+
function addPnpmPackage(items, value) {
|
|
217
|
+
let index = value.indexOf('(');
|
|
218
|
+
if (index !== -1) {
|
|
219
|
+
value = value.substring(0, index);
|
|
220
|
+
}
|
|
221
|
+
index = value.lastIndexOf(value.indexOf('@', 2) !== -1 ? '@' : '/');
|
|
222
|
+
const name = value.substring(1, index);
|
|
223
|
+
const version = value.substring(index + 1);
|
|
224
|
+
if (!items.find(item => item[0] === name && item[1] === version)) {
|
|
225
|
+
items.push([name, version]);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
209
228
|
function setYarnVer() {
|
|
210
229
|
if (YARN_VER === undefined) {
|
|
211
230
|
YARN_VER = false;
|
|
@@ -229,6 +248,55 @@ function setYarnVer() {
|
|
|
229
248
|
}
|
|
230
249
|
return YARN_VER;
|
|
231
250
|
}
|
|
251
|
+
function getYarnVersion(item, value) {
|
|
252
|
+
const dependency = item.packageDependencies.get(value);
|
|
253
|
+
if (typeof dependency === 'string') {
|
|
254
|
+
const pkg = dependency.split('npm:');
|
|
255
|
+
if (pkg.length > 1) {
|
|
256
|
+
return pkg.pop();
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
function getLatestRelease(result, unstable = false) {
|
|
261
|
+
if (result.length > 1) {
|
|
262
|
+
result.sort((a, b) => {
|
|
263
|
+
const c = a.split('.');
|
|
264
|
+
const d = b.split('.');
|
|
265
|
+
if (!unstable) {
|
|
266
|
+
const g = c.some(e => isNaN(+e));
|
|
267
|
+
const h = d.some(f => isNaN(+f));
|
|
268
|
+
if (g && !h) {
|
|
269
|
+
return 1;
|
|
270
|
+
}
|
|
271
|
+
if (h && !g) {
|
|
272
|
+
return -1;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
return (function recurse() {
|
|
276
|
+
const e = c.shift();
|
|
277
|
+
const f = d.shift();
|
|
278
|
+
if (!e || !f) {
|
|
279
|
+
return 0;
|
|
280
|
+
}
|
|
281
|
+
if (e !== f) {
|
|
282
|
+
const g = parseInt(f) - parseInt(e);
|
|
283
|
+
if (g === 0) {
|
|
284
|
+
if (isNaN(+e) && !isNaN(+f)) {
|
|
285
|
+
return 1;
|
|
286
|
+
}
|
|
287
|
+
if (isNaN(+f) && !isNaN(+e)) {
|
|
288
|
+
return -1;
|
|
289
|
+
}
|
|
290
|
+
return e < f ? 1 : -1;
|
|
291
|
+
}
|
|
292
|
+
return g;
|
|
293
|
+
}
|
|
294
|
+
return recurse();
|
|
295
|
+
})();
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
return result[0];
|
|
299
|
+
}
|
|
232
300
|
function applyStyle(options, style) {
|
|
233
301
|
var _h;
|
|
234
302
|
for (const attr in style) {
|
|
@@ -290,6 +358,28 @@ function checkColorOptions(type, settings, options) {
|
|
|
290
358
|
}
|
|
291
359
|
return result;
|
|
292
360
|
}
|
|
361
|
+
function isBackgroundColor(value) {
|
|
362
|
+
return [
|
|
363
|
+
'bgBlack',
|
|
364
|
+
'bgRed',
|
|
365
|
+
'bgGreen',
|
|
366
|
+
'bgYellow',
|
|
367
|
+
'bgBlue',
|
|
368
|
+
'bgMagenta',
|
|
369
|
+
'bgCyan',
|
|
370
|
+
'bgWhite',
|
|
371
|
+
'bgGray',
|
|
372
|
+
'bgGrey',
|
|
373
|
+
'bgBlackBright',
|
|
374
|
+
'bgRedBright',
|
|
375
|
+
'bgGreenBright',
|
|
376
|
+
'bgYellowBright',
|
|
377
|
+
'bgBlueBright',
|
|
378
|
+
'bgMagentaBright',
|
|
379
|
+
'bgCyanBright',
|
|
380
|
+
'bgWhiteBright'
|
|
381
|
+
].includes(value);
|
|
382
|
+
}
|
|
293
383
|
function tryCreateDir(value) {
|
|
294
384
|
try {
|
|
295
385
|
if (fs.mkdirSync(value, { recursive: true }) && fs.statSync(value).isDirectory()) {
|
|
@@ -458,10 +548,10 @@ function recurseCause(err, out, visited) {
|
|
|
458
548
|
out.push(message);
|
|
459
549
|
}
|
|
460
550
|
}
|
|
461
|
-
function
|
|
551
|
+
function formatError(err) {
|
|
462
552
|
const cause = [];
|
|
463
|
-
recurseCause(err, cause);
|
|
464
|
-
return (SETTINGS.stack_trace && err.stack || err.message || err.toString() || "Unknown") + (cause.length ? cause.map((value, index) => `\n\nCause #${cause.length - index}: ` + value).join('') : '');
|
|
553
|
+
recurseCause(err, cause, null);
|
|
554
|
+
return (SETTINGS.stack_trace && err.stack || err.message || err.toString() || "Unknown") + (cause.length > 0 ? cause.map((value, index) => `\n\nCause #${cause.length - index}: ` + value).join('') : '');
|
|
465
555
|
}
|
|
466
556
|
function writeLine(value) {
|
|
467
557
|
PROCESS_STDOUT.write((!LOG_NEWLINE ? '\n' : '') + value + '\n');
|
|
@@ -519,35 +609,26 @@ function getCacheItem(map, key) {
|
|
|
519
609
|
}
|
|
520
610
|
const current = Date.now();
|
|
521
611
|
if (item[0] + MEMORY_CACHE_DISK.expires >= current) {
|
|
522
|
-
--CACHE_TOTAL;
|
|
523
612
|
map.delete(key);
|
|
524
613
|
return;
|
|
525
614
|
}
|
|
526
615
|
item[0] = current;
|
|
527
616
|
return item[1];
|
|
528
617
|
}
|
|
529
|
-
function addCacheItem(map, key, data, cache) {
|
|
618
|
+
function addCacheItem(map, key, data, cache = false) {
|
|
530
619
|
const length = Buffer.byteLength(data);
|
|
531
|
-
if (length
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
if (!cache) {
|
|
536
|
-
if (MEMORY_CACHE_DISK.include) {
|
|
537
|
-
if (!MEMORY_CACHE_DISK.include.some(value => pm.isMatch(key, value, { nocase: PLATFORM_WIN32, matchBase: value.startsWith('*') }))) {
|
|
538
|
-
return;
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
|
-
else {
|
|
542
|
-
cache = true;
|
|
620
|
+
if (length >= MEMORY_CACHE_DISK.min_size && length <= MEMORY_CACHE_DISK.max_size) {
|
|
621
|
+
key = Module.toPosix(key, true);
|
|
622
|
+
if (!MEMORY_CACHE_DISK.exclude?.some(value => isMatch(key, value)) && (cache || !MEMORY_CACHE_DISK.include || MEMORY_CACHE_DISK.include.some(value => isMatch(key, value)))) {
|
|
623
|
+
map.set(key, [Date.now(), data]);
|
|
543
624
|
}
|
|
544
625
|
}
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
}
|
|
626
|
+
}
|
|
627
|
+
function getCacheTotal() {
|
|
628
|
+
return CACHE_READTEXT.size + CACHE_READBUFFER.size + CACHE_READCJS.size;
|
|
629
|
+
}
|
|
630
|
+
function isMatch(key, value) {
|
|
631
|
+
return pm.isMatch(key, value, { nocase: PLATFORM_WIN32, matchBase: value.startsWith('*') });
|
|
551
632
|
}
|
|
552
633
|
function checkFunction(value) {
|
|
553
634
|
if (typeof value === 'function') {
|
|
@@ -568,6 +649,27 @@ function encryptMessage(data, cipher, algorithm) {
|
|
|
568
649
|
}
|
|
569
650
|
return data;
|
|
570
651
|
}
|
|
652
|
+
function withinDir(value, base, override = false) {
|
|
653
|
+
value = path.normalize(value);
|
|
654
|
+
if (PLATFORM_WIN32) {
|
|
655
|
+
value = value.toLowerCase();
|
|
656
|
+
base = ensureDir(base.toLowerCase());
|
|
657
|
+
}
|
|
658
|
+
else {
|
|
659
|
+
base = ensureDir(base);
|
|
660
|
+
}
|
|
661
|
+
return value.startsWith(base) && (value !== base || override);
|
|
662
|
+
}
|
|
663
|
+
function formatPercent(value, precision) {
|
|
664
|
+
if (value <= 0) {
|
|
665
|
+
return '0%';
|
|
666
|
+
}
|
|
667
|
+
if (value === (value | 0)) {
|
|
668
|
+
return value + '00%';
|
|
669
|
+
}
|
|
670
|
+
value *= 100;
|
|
671
|
+
return value.toPrecision(value < 1 ? 2 : precision) + '%';
|
|
672
|
+
}
|
|
571
673
|
function relayMessage(instance, args) {
|
|
572
674
|
const host = instance.host || instance;
|
|
573
675
|
if (host.logState === 0) {
|
|
@@ -577,16 +679,17 @@ function relayMessage(instance, args) {
|
|
|
577
679
|
Module.formatMessage(...args);
|
|
578
680
|
}
|
|
579
681
|
}
|
|
580
|
-
function setCpuAndMem(options) {
|
|
682
|
+
function setCpuAndMem(instance, options) {
|
|
581
683
|
if (!options.messageUnit) {
|
|
582
|
-
const usage = CACHE_CPUHOST.get(
|
|
684
|
+
const usage = CACHE_CPUHOST.get(instance) || instance.host && CACHE_CPUHOST.get(instance.host);
|
|
583
685
|
if (usage) {
|
|
584
686
|
options.messageUnit = Module.formatCpuMem(usage);
|
|
585
687
|
}
|
|
586
688
|
}
|
|
587
689
|
}
|
|
588
|
-
function hasFileSystem(type, value, options, ignoreExists, overwrite) {
|
|
589
|
-
|
|
690
|
+
function hasFileSystem(instance, type, value, options, ignoreExists, overwrite) {
|
|
691
|
+
value = asFile(value);
|
|
692
|
+
if (!value) {
|
|
590
693
|
return '';
|
|
591
694
|
}
|
|
592
695
|
let result;
|
|
@@ -622,7 +725,7 @@ function hasFileSystem(type, value, options, ignoreExists, overwrite) {
|
|
|
622
725
|
}
|
|
623
726
|
const method = type === 1 ? 'canWrite' : 'canRead';
|
|
624
727
|
if (options.ownPermissionOnly) {
|
|
625
|
-
if (
|
|
728
|
+
if (instance.hasOwnPermission() && !instance[method](result)) {
|
|
626
729
|
if (options.throwsPermission) {
|
|
627
730
|
throw errorPermission(result);
|
|
628
731
|
}
|
|
@@ -630,7 +733,7 @@ function hasFileSystem(type, value, options, ignoreExists, overwrite) {
|
|
|
630
733
|
}
|
|
631
734
|
}
|
|
632
735
|
else if (options.hostPermissionOnly) {
|
|
633
|
-
const host =
|
|
736
|
+
const host = instance.host;
|
|
634
737
|
if (host?.permission && !host[method](result)) {
|
|
635
738
|
if (options.throwsPermission) {
|
|
636
739
|
throw errorPermission(result);
|
|
@@ -638,7 +741,7 @@ function hasFileSystem(type, value, options, ignoreExists, overwrite) {
|
|
|
638
741
|
return '';
|
|
639
742
|
}
|
|
640
743
|
}
|
|
641
|
-
else if (
|
|
744
|
+
else if (instance.permission && !instance[method](result)) {
|
|
642
745
|
if (options.throwsPermission) {
|
|
643
746
|
throw errorPermission(result);
|
|
644
747
|
}
|
|
@@ -646,15 +749,34 @@ function hasFileSystem(type, value, options, ignoreExists, overwrite) {
|
|
|
646
749
|
}
|
|
647
750
|
return result;
|
|
648
751
|
}
|
|
649
|
-
function
|
|
650
|
-
|
|
752
|
+
function copyBarColor(target) {
|
|
753
|
+
LOG_CPUBARCOLOR[0] = target[0];
|
|
754
|
+
LOG_CPUBARCOLOR[1] = target[1];
|
|
755
|
+
LOG_CPUBARCOLOR[2] = target[2];
|
|
756
|
+
}
|
|
757
|
+
function checkExDev(err, src, dest) {
|
|
758
|
+
if (Module.isErrorCode(err, 'EXDEV')) {
|
|
759
|
+
try {
|
|
760
|
+
fs.copyFileSync(src, dest);
|
|
761
|
+
fs.unlinkSync(src);
|
|
762
|
+
return true;
|
|
763
|
+
}
|
|
764
|
+
catch {
|
|
765
|
+
fs.unlink(dest, () => { });
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
return false;
|
|
769
|
+
}
|
|
770
|
+
function applySessionId(instance, options) {
|
|
771
|
+
options.sessionId ?? (options.sessionId = instance.sessionId);
|
|
651
772
|
let value = options.broadcastId;
|
|
652
773
|
if (value === undefined) {
|
|
653
|
-
|
|
654
|
-
|
|
774
|
+
value = instance.broadcastId;
|
|
775
|
+
if (value) {
|
|
776
|
+
options.broadcastId = instance.supports('stripAnsi') ? value : { value, stripAnsi: false };
|
|
655
777
|
}
|
|
656
778
|
}
|
|
657
|
-
else if (!
|
|
779
|
+
else if (!instance.supports('stripAnsi')) {
|
|
658
780
|
if ((0, types_1.isPlainObject)(value)) {
|
|
659
781
|
value.stripAnsi = false;
|
|
660
782
|
}
|
|
@@ -664,33 +786,131 @@ function applyLogId(options) {
|
|
|
664
786
|
}
|
|
665
787
|
return options;
|
|
666
788
|
}
|
|
667
|
-
function
|
|
668
|
-
|
|
669
|
-
if (
|
|
670
|
-
value
|
|
671
|
-
|
|
789
|
+
function getSessionId(value, width) {
|
|
790
|
+
const id = SETTINGS.session_id;
|
|
791
|
+
if (id > 0) {
|
|
792
|
+
return [value ? ' ' + value.padStart(id, '0') + ' ' : ' '.repeat(id + 2), Math.max(width - id - 2, 1)];
|
|
793
|
+
}
|
|
794
|
+
return ['', width - 1];
|
|
795
|
+
}
|
|
796
|
+
function alignLogColumn(value, width, justify, padding) {
|
|
797
|
+
const length = (padding === 0 && REGEXP_ANSIESCAPE.test(value) ? stripansi(value) : value).length;
|
|
798
|
+
const offset = width - length;
|
|
799
|
+
const spacing = padding === 1 ? ' ' : '';
|
|
800
|
+
if (offset <= 0) {
|
|
801
|
+
return offset === 0 && padding > 0 ? justify === 'left' ? spacing + value : value + spacing : value;
|
|
802
|
+
}
|
|
803
|
+
switch (justify) {
|
|
804
|
+
case 'right':
|
|
805
|
+
return ' '.repeat(offset) + value + spacing;
|
|
806
|
+
case 'center': {
|
|
807
|
+
width = offset + padding;
|
|
808
|
+
const leading = Math.floor(width / 2);
|
|
809
|
+
return ' '.repeat(leading) + value + ' '.repeat(width - leading);
|
|
810
|
+
}
|
|
811
|
+
default:
|
|
812
|
+
return spacing + value + ' '.repeat(offset);
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
function formatLogColumn(value, color, bgColor, bold, bgAltColor = '', options) {
|
|
816
|
+
let indent = '', length = 0, output;
|
|
817
|
+
if (typeof value === 'string') {
|
|
818
|
+
output = value;
|
|
819
|
+
let modified;
|
|
820
|
+
if (bgAltColor) {
|
|
821
|
+
const match = /^([ -]+)(.*)$/s.exec(output);
|
|
822
|
+
if (match) {
|
|
823
|
+
indent = match[1];
|
|
824
|
+
length += indent.length;
|
|
825
|
+
output = match[2];
|
|
826
|
+
try {
|
|
827
|
+
indent = tryWrapColor(match[1], bgAltColor, true);
|
|
828
|
+
}
|
|
829
|
+
catch {
|
|
830
|
+
}
|
|
831
|
+
modified = true;
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
if (!modified && !output.trim()) {
|
|
835
|
+
return output;
|
|
836
|
+
}
|
|
672
837
|
}
|
|
673
838
|
else {
|
|
674
|
-
|
|
839
|
+
output = Module.asString(value);
|
|
675
840
|
}
|
|
676
|
-
|
|
841
|
+
if (options) {
|
|
842
|
+
const messageTextWrap = options.messageTextWrap;
|
|
843
|
+
let maxLength = options.maxLength ?? (!messageTextWrap || messageTextWrap === 'none' ? Infinity : NaN);
|
|
844
|
+
if (maxLength !== Infinity) {
|
|
845
|
+
if (maxLength === 0) {
|
|
846
|
+
return '';
|
|
847
|
+
}
|
|
848
|
+
if (isNaN(maxLength)) {
|
|
849
|
+
maxLength = PROCESS_STDOUT.columns - LOG_MIN_WIDTH;
|
|
850
|
+
}
|
|
851
|
+
if (maxLength <= 0) {
|
|
852
|
+
return '';
|
|
853
|
+
}
|
|
854
|
+
output = truncateStart(output, maxLength, messageTextWrap);
|
|
855
|
+
}
|
|
856
|
+
options.outLength = length + output.length;
|
|
857
|
+
}
|
|
858
|
+
if (color || bgColor) {
|
|
859
|
+
try {
|
|
860
|
+
let current = bold ? chalk.bold : chalk;
|
|
861
|
+
if (typeof color === 'string' && color.length > 1) {
|
|
862
|
+
current = color.startsWith('#') ? current.hex(color) : current[color];
|
|
863
|
+
}
|
|
864
|
+
if (typeof bgColor === 'string' && bgColor.length > 1) {
|
|
865
|
+
current = bgColor.startsWith('#') ? current.bgHex(bgColor) : current[bgColor];
|
|
866
|
+
}
|
|
867
|
+
return indent + current(output);
|
|
868
|
+
}
|
|
869
|
+
catch {
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
return indent + (bold ? chalk.bold(output) : output);
|
|
677
873
|
}
|
|
678
|
-
function
|
|
679
|
-
|
|
680
|
-
|
|
874
|
+
function setLogMinWidth() {
|
|
875
|
+
const format = SETTINGS.format;
|
|
876
|
+
LOG_MIN_WIDTH = format.title.width + 2 + format.value.width + format.message.braces.reduce((a, b) => a + b.length, 1);
|
|
877
|
+
}
|
|
878
|
+
function tryWrapColor(value, color, background) {
|
|
879
|
+
return (color.startsWith('#') ? chalk[background ? 'bgHex' : 'hex'](color) : chalk[color])(value);
|
|
880
|
+
}
|
|
881
|
+
function truncateStart(value, length = LOG_MIN_WIDTH, style = false) {
|
|
882
|
+
if (!style || style === 'none') {
|
|
883
|
+
return value;
|
|
681
884
|
}
|
|
682
|
-
|
|
683
|
-
|
|
885
|
+
const width = (REGEXP_ANSIESCAPE.test(value) ? stripansi(value) : value).length;
|
|
886
|
+
if (width > length) {
|
|
887
|
+
switch (style) {
|
|
888
|
+
case 'nowrap':
|
|
889
|
+
return value.substring(0, length);
|
|
890
|
+
case 'nowrap-end':
|
|
891
|
+
return value.substring(width - length);
|
|
892
|
+
default:
|
|
893
|
+
if (length > 3) {
|
|
894
|
+
return style === 'ellipsis-end' ? '...' + value.substring(width - length + 3) : value.substring(0, length - 3) + '...';
|
|
895
|
+
}
|
|
896
|
+
break;
|
|
897
|
+
}
|
|
684
898
|
}
|
|
685
|
-
value
|
|
686
|
-
|
|
899
|
+
return length > 0 && width <= length ? value : '';
|
|
900
|
+
}
|
|
901
|
+
function truncateEnd(value, length) {
|
|
902
|
+
return (REGEXP_ANSIESCAPE.test(value) ? stripansi(value) : value).length > length ? '...' + value.substring(value.length - length + 3) : value;
|
|
687
903
|
}
|
|
904
|
+
const escapeArg = (value) => value.replace(REGEXP_CLIESCAPE, capture => (capture === '$' || capture === '`' ? '\\' : '') + '\\' + capture);
|
|
905
|
+
const isMeterUnit = (type, ident) => (type & 256) === 256 && !ident;
|
|
906
|
+
const formatLogMessage = (type, message, unit, ident) => isMeterUnit(type, ident) ? (unit + LOG_DIVIDER + message).trimEnd() : unit ? (message + (ident ? '' : ' ') + unit).trimStart() : message;
|
|
688
907
|
const hideAbort = (err) => err.name === 'AbortError' && SETTINGS.abort === false;
|
|
689
|
-
const asFile = (value) => typeof value === 'string' ? value.trim() : value instanceof URL && value.protocol === 'file:' ?
|
|
690
|
-
const wrapQuote = (value) => '"' + value.
|
|
908
|
+
const asFile = (value) => typeof value === 'string' ? value.trim() : value instanceof URL && value.protocol === 'file:' ? (0, url_1.fileURLToPath)(value) : '';
|
|
909
|
+
const wrapQuote = (value) => '"' + value.replaceAll('"', '\\"') + '"';
|
|
691
910
|
const isFunction = (value) => typeof value === 'function';
|
|
692
911
|
const isFileURL = (value) => /^file:\/\//i.test(value);
|
|
693
912
|
const sanitizePath = (value) => value ? path.resolve(value) : '';
|
|
913
|
+
const stripPath = (value) => path.normalize(value).replace(/[\\/]+$/, '');
|
|
694
914
|
const ensureDir = (value) => value.endsWith(path.sep) ? value : value + path.sep;
|
|
695
915
|
const trimDir = (value) => value.endsWith(path.sep) ? value.substring(0, value.length - 1) : value;
|
|
696
916
|
const getExtension = (value) => path.extname(value).toLowerCase().substring(1);
|
|
@@ -699,7 +919,8 @@ const getCpuTimes = () => os.cpus().reduce((a, b) => a + b.times.user + b.times.
|
|
|
699
919
|
const autoMemoryCache = () => MEMORY_CACHE_DISK.enabled && MEMORY_CACHE_DISK.max_size > 0;
|
|
700
920
|
const errorDirectory = (value) => (0, types_1.errorValue)("Path is not a directory", value);
|
|
701
921
|
const errorPermission = (value) => (0, types_1.errorValue)("Unsupported access", asFile(value));
|
|
702
|
-
const
|
|
922
|
+
const errorAccess = (failed) => (0, types_1.errorMessage)("Unsupported access", failed.length > 1 ? failed.map(value => `\n- ${value}`).join('') : ' ' + failed[0]);
|
|
923
|
+
const errorUnknown = (err, hint) => err instanceof Error ? 'code' in err || 'errno' in err ? err : (0, types_1.errorMessage)("Unknown", err.message, hint) : (0, types_1.errorValue)("Unknown", hint);
|
|
703
924
|
class Module extends EventEmitter {
|
|
704
925
|
constructor() {
|
|
705
926
|
super(...arguments);
|
|
@@ -707,6 +928,7 @@ class Module extends EventEmitter {
|
|
|
707
928
|
this.errors = [];
|
|
708
929
|
this._moduleName = 'unknown';
|
|
709
930
|
this._host = null;
|
|
931
|
+
this._silent = null;
|
|
710
932
|
this._abortable = false;
|
|
711
933
|
this._threadable = false;
|
|
712
934
|
this._logEnabled = true;
|
|
@@ -722,26 +944,29 @@ class Module extends EventEmitter {
|
|
|
722
944
|
this[_f] = new AbortController();
|
|
723
945
|
this[_g] = null;
|
|
724
946
|
}
|
|
725
|
-
static get VERSION() {
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
static get
|
|
729
|
-
|
|
730
|
-
|
|
947
|
+
static get VERSION() {
|
|
948
|
+
return "0.10.1";
|
|
949
|
+
}
|
|
950
|
+
static get LOG_TYPE() {
|
|
951
|
+
return types_1.LOG_TYPE;
|
|
952
|
+
}
|
|
953
|
+
static get STATUS_TYPE() {
|
|
954
|
+
return types_1.STATUS_TYPE;
|
|
955
|
+
}
|
|
956
|
+
static get PLATFORM_WIN32() {
|
|
957
|
+
return PLATFORM_WIN32;
|
|
958
|
+
}
|
|
959
|
+
static get MAX_TIMEOUT() {
|
|
960
|
+
return 2147483647;
|
|
961
|
+
}
|
|
962
|
+
static get TEMP_DIR() {
|
|
963
|
+
return TEMP_DIR;
|
|
964
|
+
}
|
|
965
|
+
static get LOG_FORMAT() {
|
|
966
|
+
return (0, types_1.cloneObject)(SETTINGS.format, true);
|
|
967
|
+
}
|
|
731
968
|
static supported(major, minor = 0, patch = 0, lts) {
|
|
732
|
-
|
|
733
|
-
return false;
|
|
734
|
-
}
|
|
735
|
-
if (VER_MAJOR === major) {
|
|
736
|
-
if (VER_MINOR < minor) {
|
|
737
|
-
return false;
|
|
738
|
-
}
|
|
739
|
-
if (VER_MINOR === minor) {
|
|
740
|
-
return VER_PATCH >= patch;
|
|
741
|
-
}
|
|
742
|
-
return true;
|
|
743
|
-
}
|
|
744
|
-
return !lts;
|
|
969
|
+
return (0, types_1.supported)(major, minor, patch, lts);
|
|
745
970
|
}
|
|
746
971
|
static enabled(key, username) {
|
|
747
972
|
switch (key) {
|
|
@@ -813,7 +1038,7 @@ class Module extends EventEmitter {
|
|
|
813
1038
|
}
|
|
814
1039
|
const BROADCAST_OUT = VALUES["broadcast.out"];
|
|
815
1040
|
const sessionId = options.sessionId;
|
|
816
|
-
let broadcastId = options.broadcastId;
|
|
1041
|
+
let broadcastId = options.broadcastId, output;
|
|
817
1042
|
if ((type & 512) === 512 && VALUES["error.out"]) {
|
|
818
1043
|
try {
|
|
819
1044
|
const ERROR_OUT = VALUES["error.out"];
|
|
@@ -831,256 +1056,235 @@ class Module extends EventEmitter {
|
|
|
831
1056
|
if (broadcastId && !BROADCAST_OUT || (!SETTINGS.enabled || !this.hasLogType(type) && !options.alwaysVisible) && !(broadcastId && BROADCAST_OUT)) {
|
|
832
1057
|
return;
|
|
833
1058
|
}
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
(
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
}
|
|
856
|
-
if (messageUnitIndent) {
|
|
857
|
-
let indentChar;
|
|
858
|
-
if (Array.isArray(messageUnitIndent)) {
|
|
859
|
-
[messageUnitIndent, indentChar] = messageUnitIndent;
|
|
860
|
-
}
|
|
861
|
-
if (messageUnitIndent > 0) {
|
|
862
|
-
message = (indentChar || ' ').repeat(messageUnitIndent) + this.asString(message);
|
|
863
|
-
}
|
|
864
|
-
}
|
|
865
|
-
const truncateStart = (content, length = 0) => length > 3 && content.length > length ? content.substring(0, length - 3) + '...' : content;
|
|
866
|
-
const truncateEnd = (content, length) => content.length > length ? '...' + content.substring(content.length - length + 3) : content;
|
|
867
|
-
const getValue = () => alignColumn(truncateEnd(value, valueWidth - (titleIndent > 0 ? titleIndent - formatTitle.width : !title && message ? -(formatTitle.width + 3) : 0) - 1), valueWidth, formatValue.justify);
|
|
868
|
-
const alignColumn = (content, width, justify, padding = 0) => {
|
|
869
|
-
const offset = width - content.length;
|
|
870
|
-
const spacing = padding === 1 ? ' ' : padding > 0 ? ' '.repeat(padding) : '';
|
|
871
|
-
if (offset <= 0) {
|
|
872
|
-
return offset === 0 && padding > 0 ? justify === 'left' ? spacing + content : content + spacing : content;
|
|
873
|
-
}
|
|
874
|
-
switch (justify) {
|
|
875
|
-
case 'right':
|
|
876
|
-
return content.padStart(width) + spacing;
|
|
877
|
-
case 'center':
|
|
878
|
-
return content.padStart(content.length + Math.ceil((offset + padding) / 2)).padEnd(width + padding);
|
|
879
|
-
default:
|
|
880
|
-
return spacing + content.padEnd(width);
|
|
1059
|
+
if (!options.rawOutput) {
|
|
1060
|
+
let messageUnitIndent = options.messageUnitIndent, coloring;
|
|
1061
|
+
if (!broadcastId) {
|
|
1062
|
+
(0, types_1.setLogCurrent)({ type, title, value, message, sessionId });
|
|
1063
|
+
coloring = !(options.useColor === false || SETTINGS.color === false);
|
|
1064
|
+
}
|
|
1065
|
+
else if ((0, types_1.isPlainObject)(broadcastId)) {
|
|
1066
|
+
coloring = broadcastId.stripAnsi === false;
|
|
1067
|
+
broadcastId = broadcastId.value;
|
|
1068
|
+
}
|
|
1069
|
+
const format = SETTINGS.format;
|
|
1070
|
+
const formatTitle = format.title;
|
|
1071
|
+
const formatValue = format.value;
|
|
1072
|
+
const titleIndent = options.titleIndent ? typeof options.titleIndent === 'number' ? Math.max(options.titleIndent, 0) : 0 : -1;
|
|
1073
|
+
let [id, valueWidth] = getSessionId(sessionId, formatValue.width), hint, titleJustify = options.titleJustify || ((type & 512) || options.failed ? 'center' : formatTitle.justify);
|
|
1074
|
+
const getValue = () => {
|
|
1075
|
+
return alignLogColumn(truncateEnd(value, valueWidth - (titleIndent > 0 ? titleIndent - formatTitle.width : !title && message ? -(formatTitle.width + 2) : 0) - 1), valueWidth, formatValue.justify, 0);
|
|
1076
|
+
};
|
|
1077
|
+
if (Array.isArray(value)) {
|
|
1078
|
+
hint = value[1] ?? '';
|
|
1079
|
+
value = value[0];
|
|
881
1080
|
}
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
if (content === undefined || content === null) {
|
|
885
|
-
return '';
|
|
1081
|
+
if (error) {
|
|
1082
|
+
message = formatError(message);
|
|
886
1083
|
}
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
const match = /^([ -]+)([\S\s]*)$/.exec(content);
|
|
892
|
-
if (match) {
|
|
893
|
-
indent = match[1];
|
|
894
|
-
if (bgAltColor) {
|
|
895
|
-
try {
|
|
896
|
-
indent = (bgAltColor.startsWith('#') ? chalk.bgHex(bgAltColor) : chalk[bgAltColor])(indent);
|
|
897
|
-
}
|
|
898
|
-
catch {
|
|
899
|
-
}
|
|
900
|
-
}
|
|
901
|
-
content = match[2];
|
|
902
|
-
modified = true;
|
|
903
|
-
}
|
|
1084
|
+
if (messageUnitIndent) {
|
|
1085
|
+
let indentChar;
|
|
1086
|
+
if (Array.isArray(messageUnitIndent)) {
|
|
1087
|
+
[messageUnitIndent, indentChar] = messageUnitIndent;
|
|
904
1088
|
}
|
|
905
|
-
if (
|
|
906
|
-
|
|
1089
|
+
if (messageUnitIndent > 0) {
|
|
1090
|
+
message = (indentChar || ' ').repeat(messageUnitIndent) + this.asString(message);
|
|
1091
|
+
}
|
|
1092
|
+
else {
|
|
1093
|
+
messageUnitIndent = 0;
|
|
907
1094
|
}
|
|
908
1095
|
}
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
}
|
|
912
|
-
if (maxLength > 0) {
|
|
913
|
-
content = truncateStart(content, maxLength);
|
|
1096
|
+
if (type === 0) {
|
|
1097
|
+
checkColorOptions(type, SETTINGS.unknown, options);
|
|
914
1098
|
}
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
1099
|
+
else {
|
|
1100
|
+
if (type & 4096) {
|
|
1101
|
+
checkColorOptions(type, SETTINGS.exec, options);
|
|
1102
|
+
}
|
|
1103
|
+
else if (type & 32) {
|
|
1104
|
+
checkColorOptions(type, SETTINGS.file, options);
|
|
1105
|
+
}
|
|
1106
|
+
else if (type & 2) {
|
|
1107
|
+
if (!checkColorOptions(type, SETTINGS.node, options)) {
|
|
1108
|
+
applyStyle(options, this.LOG_STYLE_REVERSE);
|
|
1109
|
+
options.hintColor || (options.hintColor = 'yellow');
|
|
920
1110
|
}
|
|
921
|
-
|
|
922
|
-
|
|
1111
|
+
titleJustify = 'center';
|
|
1112
|
+
}
|
|
1113
|
+
else if (type & 1) {
|
|
1114
|
+
checkColorOptions(type, SETTINGS.system, options);
|
|
1115
|
+
if (options.titleBgColor) {
|
|
1116
|
+
titleJustify = 'center';
|
|
923
1117
|
}
|
|
924
|
-
return indent + current(content);
|
|
925
1118
|
}
|
|
926
|
-
|
|
1119
|
+
if (type & 1024) {
|
|
1120
|
+
checkColorOptions(type, SETTINGS.http, options);
|
|
927
1121
|
}
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
};
|
|
931
|
-
if (type === 0) {
|
|
932
|
-
checkColorOptions(type, SETTINGS.unknown, options);
|
|
933
|
-
}
|
|
934
|
-
else {
|
|
935
|
-
if (type & 4096) {
|
|
936
|
-
checkColorOptions(type, SETTINGS.exec, options);
|
|
937
|
-
}
|
|
938
|
-
else if (type & 32) {
|
|
939
|
-
checkColorOptions(type, SETTINGS.file, options);
|
|
940
|
-
}
|
|
941
|
-
else if (type & 2) {
|
|
942
|
-
if (!checkColorOptions(type, SETTINGS.node, options)) {
|
|
943
|
-
applyStyle(options, this.LOG_STYLE_REVERSE);
|
|
944
|
-
options.hintColor || (options.hintColor = 'yellow');
|
|
1122
|
+
else if (type & 64) {
|
|
1123
|
+
checkColorOptions(type, SETTINGS.cloud, options);
|
|
945
1124
|
}
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
1125
|
+
else if (type & 65536) {
|
|
1126
|
+
checkColorOptions(type, SETTINGS.db, options);
|
|
1127
|
+
}
|
|
1128
|
+
else if (type & 16) {
|
|
1129
|
+
checkColorOptions(type, SETTINGS.watch, options);
|
|
951
1130
|
titleJustify = 'center';
|
|
952
1131
|
}
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
checkColorOptions(type, SETTINGS.http, options);
|
|
956
|
-
}
|
|
957
|
-
else if (type & 64) {
|
|
958
|
-
checkColorOptions(type, SETTINGS.cloud, options);
|
|
959
|
-
}
|
|
960
|
-
else if (type & 65536) {
|
|
961
|
-
checkColorOptions(type, SETTINGS.db, options);
|
|
962
|
-
}
|
|
963
|
-
else if (type & 16) {
|
|
964
|
-
checkColorOptions(type, SETTINGS.watch, options);
|
|
965
|
-
titleJustify = 'center';
|
|
966
|
-
}
|
|
967
|
-
else if (type & 2048) {
|
|
968
|
-
checkColorOptions(type, SETTINGS.image, options);
|
|
969
|
-
}
|
|
970
|
-
else if (type & 8) {
|
|
971
|
-
checkColorOptions(type, SETTINGS.compress, options);
|
|
972
|
-
}
|
|
973
|
-
else if ((type & 4) && !options.titleColor && !checkColorOptions(type, SETTINGS.process, options)) {
|
|
974
|
-
options.titleColor = 'magenta';
|
|
975
|
-
}
|
|
976
|
-
if (type & 128) {
|
|
977
|
-
if (!checkColorOptions(type, SETTINGS.time_elapsed, options)) {
|
|
978
|
-
options.hintColor || (options.hintColor = 'yellow');
|
|
1132
|
+
else if (type & 2048) {
|
|
1133
|
+
checkColorOptions(type, SETTINGS.image, options);
|
|
979
1134
|
}
|
|
980
|
-
if (
|
|
981
|
-
|
|
1135
|
+
else if (type & 8) {
|
|
1136
|
+
checkColorOptions(type, SETTINGS.compress, options);
|
|
982
1137
|
}
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
if (options.failed) {
|
|
986
|
-
options.messageBgColor || (options.messageBgColor = 'bgGrey');
|
|
1138
|
+
else if ((type & 4) && !options.titleColor && !checkColorOptions(type, SETTINGS.process, options)) {
|
|
1139
|
+
options.titleColor = 'magenta';
|
|
987
1140
|
}
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
1141
|
+
if (type & 128) {
|
|
1142
|
+
if (!checkColorOptions(type, SETTINGS.time_elapsed, options)) {
|
|
1143
|
+
options.hintColor || (options.hintColor = 'yellow');
|
|
1144
|
+
}
|
|
1145
|
+
if (options.titleBgColor) {
|
|
1146
|
+
titleJustify = 'center';
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1149
|
+
else if (type & 256) {
|
|
1150
|
+
if (options.failed) {
|
|
1151
|
+
options.messageBgColor || (options.messageBgColor = 'bgGrey');
|
|
1152
|
+
}
|
|
1153
|
+
else {
|
|
1154
|
+
const { color, bgColor, bold } = format.meter;
|
|
1155
|
+
if (!options.messageBgColor && !options.messageColor) {
|
|
1156
|
+
if (color) {
|
|
1157
|
+
options.messageColor = color;
|
|
1158
|
+
}
|
|
1159
|
+
if (bgColor) {
|
|
1160
|
+
options.messageBgColor = bgColor;
|
|
1161
|
+
}
|
|
993
1162
|
}
|
|
994
|
-
if (
|
|
995
|
-
options.
|
|
1163
|
+
if (bold) {
|
|
1164
|
+
options.messageBold ?? (options.messageBold = true);
|
|
996
1165
|
}
|
|
997
1166
|
}
|
|
998
|
-
if (bold) {
|
|
999
|
-
options.messageBold ?? (options.messageBold = true);
|
|
1000
|
-
}
|
|
1001
1167
|
}
|
|
1002
1168
|
}
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
value = getValue();
|
|
1020
|
-
hint = coloring ? chalk.blackBright('[') + formatColumn(truncateEnd(hint, hintWidth), hintColor, hintBgColor, hintBold) + chalk.blackBright(']') : `[${truncateEnd(hint, hintWidth)}]`;
|
|
1021
|
-
}
|
|
1022
|
-
else {
|
|
1023
|
-
if (title) {
|
|
1169
|
+
title = titleIndent !== -1 ? ' '.repeat(titleIndent || (formatTitle.width + 3)) : (0, types_1.isString)(title) ? (title = title.toUpperCase(), alignLogColumn(formatTitle.as[title] || title, formatTitle.width, titleJustify, 1)) : '';
|
|
1170
|
+
if ((0, types_1.isString)(hint)) {
|
|
1171
|
+
const formatHint = format.hint;
|
|
1172
|
+
const [L, R] = formatHint.braces;
|
|
1173
|
+
let { hintColor, hintBgColor, hintBold } = options, hintWidth = formatHint.width;
|
|
1174
|
+
hint = formatHint.as[hint] || hint;
|
|
1175
|
+
valueWidth -= Math.min(hint.length, hintWidth) + L.length + R.length;
|
|
1176
|
+
if (hint.length > hintWidth && value.length < valueWidth) {
|
|
1177
|
+
const offset = Math.min(valueWidth - value.length, hint.length - hintWidth);
|
|
1178
|
+
hintWidth += offset;
|
|
1179
|
+
valueWidth -= offset;
|
|
1180
|
+
}
|
|
1181
|
+
if (!hintColor && !hintBgColor) {
|
|
1182
|
+
({ color: hintColor, bgColor: hintBgColor } = formatHint);
|
|
1183
|
+
hintBold ?? (hintBold = formatHint.bold);
|
|
1184
|
+
}
|
|
1024
1185
|
value = getValue();
|
|
1186
|
+
hint = coloring ? (L && chalk.blackBright(L)) + formatLogColumn(truncateEnd(hint, hintWidth), hintColor, hintBgColor, hintBold) + chalk.blackBright(R) : L + truncateEnd(hint, hintWidth) + R;
|
|
1025
1187
|
}
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
({ color: titleColor, bgColor: titleBgColor } = formatTitle);
|
|
1188
|
+
else {
|
|
1189
|
+
const R = format.hint.braces[1];
|
|
1190
|
+
hint = coloring ? chalk.blackBright(R) : R;
|
|
1191
|
+
if (title) {
|
|
1192
|
+
valueWidth -= R.length;
|
|
1193
|
+
value = getValue();
|
|
1194
|
+
}
|
|
1034
1195
|
}
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1196
|
+
let unit = options.messageUnit || '';
|
|
1197
|
+
if ((type & 256) && options.messageUnitMinWidth) {
|
|
1198
|
+
unit = unit.padStart(options.messageUnitMinWidth);
|
|
1038
1199
|
}
|
|
1039
|
-
|
|
1040
|
-
let
|
|
1041
|
-
if (
|
|
1042
|
-
|
|
1043
|
-
i = sessionIdColor || sessionIdBgColor || sessionIdBold ? formatColumn(i, sessionIdColor, sessionIdBgColor, sessionIdBold) : chalk.grey(i);
|
|
1200
|
+
if (coloring) {
|
|
1201
|
+
let { titleColor, titleBgColor, valueColor, valueBgColor, valueBold, messageWidth, messageColor, messageBgColor, messageBold } = options;
|
|
1202
|
+
if (!titleColor && !titleBgColor) {
|
|
1203
|
+
({ color: titleColor, bgColor: titleBgColor } = formatTitle);
|
|
1044
1204
|
}
|
|
1045
|
-
if (
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
if (
|
|
1059
|
-
|
|
1060
|
-
|
|
1205
|
+
if (!valueColor && !valueBgColor) {
|
|
1206
|
+
({ color: valueColor, bgColor: valueBgColor } = formatValue);
|
|
1207
|
+
valueBold ?? (valueBold = formatValue.bold);
|
|
1208
|
+
}
|
|
1209
|
+
try {
|
|
1210
|
+
let v = value, i = id, m = message;
|
|
1211
|
+
if (i) {
|
|
1212
|
+
const { color: sessionIdColor, bgColor: sessionIdBgColor, bold: sessionIdBold } = format.session_id;
|
|
1213
|
+
i = sessionIdColor || sessionIdBgColor || sessionIdBold ? formatLogColumn(i, sessionIdColor, sessionIdBgColor, sessionIdBold) : chalk.grey(i);
|
|
1214
|
+
}
|
|
1215
|
+
if ((m || unit) && SETTINGS.message !== false) {
|
|
1216
|
+
if (!error) {
|
|
1217
|
+
const formatMessage = format.message;
|
|
1218
|
+
if (!messageColor && !messageBgColor) {
|
|
1219
|
+
({ color: messageColor, bgColor: messageBgColor, bold: messageBold } = formatMessage);
|
|
1220
|
+
messageBold ?? (messageBold = formatMessage.bold);
|
|
1221
|
+
}
|
|
1222
|
+
const [L, R] = formatMessage.braces;
|
|
1223
|
+
let u = unit;
|
|
1224
|
+
if (u) {
|
|
1225
|
+
if ((0, types_1.isObject)(SETTINGS.time_process)) {
|
|
1226
|
+
const time_process = SETTINGS.time_process;
|
|
1227
|
+
u = formatLogColumn(u, time_process.messageColor || 'grey', time_process.messageBgColor, time_process.messageBold);
|
|
1228
|
+
}
|
|
1229
|
+
else {
|
|
1230
|
+
u = formatLogColumn(u, 'grey', '', false);
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
const messageTextWrap = options.messageTextWrap;
|
|
1234
|
+
const logOptions = { maxLength: messageWidth ?? formatMessage.width, outLength: 0, messageTextWrap };
|
|
1235
|
+
m = formatLogColumn(m, messageColor, messageBgColor, messageBold, messageUnitIndent ? format.meter.bgAltColor : undefined, logOptions);
|
|
1236
|
+
if (u && messageTextWrap && messageTextWrap !== 'none' && LOG_MIN_WIDTH + logOptions.outLength + stripansi(unit).length + (messageUnitIndent ? 0 : 1) > PROCESS_STDOUT.columns) {
|
|
1237
|
+
if (isMeterUnit(type, messageUnitIndent)) {
|
|
1238
|
+
m = '';
|
|
1239
|
+
if (LOG_MIN_WIDTH + stripansi(u).length > PROCESS_STDOUT.columns) {
|
|
1240
|
+
u = '';
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
else {
|
|
1244
|
+
u = '';
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1247
|
+
if (m) {
|
|
1248
|
+
m = chalk.blackBright(L) + (u ? formatLogMessage(type, m, u, messageUnitIndent) : m);
|
|
1061
1249
|
}
|
|
1062
1250
|
else {
|
|
1063
|
-
|
|
1251
|
+
m = chalk.blackBright(L) + u;
|
|
1252
|
+
}
|
|
1253
|
+
if (R) {
|
|
1254
|
+
m = m + chalk.blackBright(R);
|
|
1255
|
+
}
|
|
1256
|
+
}
|
|
1257
|
+
else if (m) {
|
|
1258
|
+
let altColor;
|
|
1259
|
+
({ color: messageColor, altColor, bgColor: messageBgColor, bold: messageBold } = format.error);
|
|
1260
|
+
const [L, R] = format.error.braces;
|
|
1261
|
+
try {
|
|
1262
|
+
m = tryWrapColor(L, altColor, false) + formatLogColumn(m, messageColor, messageBgColor, messageBold) + (R && tryWrapColor(R, altColor, false));
|
|
1263
|
+
}
|
|
1264
|
+
catch {
|
|
1265
|
+
m = chalk.redBright(L) + chalk.bgWhite.blackBright(m) + (R && chalk.redBright(R));
|
|
1064
1266
|
}
|
|
1065
1267
|
}
|
|
1066
|
-
m = formatColumn(m, messageColor, messageBgColor, messageBold, messageUnitIndent !== undefined ? format.meter.bgAltColor : undefined, messageWidth);
|
|
1067
|
-
m = chalk.blackBright('(') + getMessage(m, u) + chalk.blackBright(')');
|
|
1068
1268
|
}
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1269
|
+
else {
|
|
1270
|
+
const [L, R] = format.message.braces;
|
|
1271
|
+
m = !R ? chalk.blackBright(L) : '';
|
|
1272
|
+
if (!hint && !i && !m) {
|
|
1273
|
+
v = v.trim();
|
|
1274
|
+
}
|
|
1073
1275
|
}
|
|
1074
|
-
|
|
1276
|
+
output = (titleIndent !== -1 ? title : title ? formatLogColumn(title, titleColor || 'green', titleBgColor, (options.titleBold || formatTitle.bold) ?? false) + chalk.blackBright(formatTitle.braces) + ' ' : '') + formatLogColumn(v, valueColor, valueBgColor, valueBold) + hint + (i || ' ') + m;
|
|
1277
|
+
}
|
|
1278
|
+
catch {
|
|
1075
1279
|
}
|
|
1076
|
-
output = (titleIndent !== -1 ? title : title ? formatColumn(title, titleColor || 'green', titleBgColor, (options.titleBold || formatTitle.bold) ?? false) + chalk.blackBright(':') + ' ' : '') + formatColumn(v, valueColor, valueBgColor, valueBold) + hint + (i || ' ') + m;
|
|
1077
1280
|
}
|
|
1078
|
-
|
|
1281
|
+
if (!output) {
|
|
1282
|
+
const formatMessage = format.message;
|
|
1283
|
+
output = (titleIndent !== -1 ? title : title ? title + formatTitle.braces + ' ' : '') + stripansi(value) + stripansi(hint) + (id || ' ') + (message && SETTINGS.message !== false ? (error ? '{' : formatMessage.braces[0]) + truncateStart(formatLogMessage(type, stripansi(this.asString(message)), stripansi(unit), messageUnitIndent), options.messageWidth ?? formatMessage.width, options.messageTextWrap) + (error ? '}' : formatMessage.braces[1]) : !formatMessage.braces[1] ? formatMessage.braces[0] : '');
|
|
1079
1284
|
}
|
|
1080
1285
|
}
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
output = (titleIndent !== -1 ? title : title ? title + ': ' : '') + stripansi(value) + stripansi(hint) + (id || ' ') + (m && SETTINGS.message !== false ? (error ? '{' : '(') + getMessage(m, unit) + (error ? '}' : ')') : '');
|
|
1286
|
+
else {
|
|
1287
|
+
output = this.asString(message);
|
|
1084
1288
|
}
|
|
1085
1289
|
if (broadcastId) {
|
|
1086
1290
|
if (BROADCAST_OUT) {
|
|
@@ -1117,8 +1321,8 @@ class Module extends EventEmitter {
|
|
|
1117
1321
|
PROCESS_STDOUT.write('\n' + output);
|
|
1118
1322
|
}
|
|
1119
1323
|
else {
|
|
1120
|
-
PROCESS_STDOUT.clearLine(0);
|
|
1121
1324
|
PROCESS_STDOUT.cursorTo(0);
|
|
1325
|
+
PROCESS_STDOUT.clearLine(0);
|
|
1122
1326
|
PROCESS_STDOUT.write(output);
|
|
1123
1327
|
}
|
|
1124
1328
|
LOG_NEWLINE = false;
|
|
@@ -1175,7 +1379,7 @@ class Module extends EventEmitter {
|
|
|
1175
1379
|
}
|
|
1176
1380
|
if (external && !pathname && VALUES["node.require.npm"] && /^(?:@[a-z\d-*~][a-z\d-*._~]*\/|node:)?[a-z\d-~][a-z\d-._~]*(?:\/.*)?$/.test(location)) {
|
|
1177
1381
|
try {
|
|
1178
|
-
result = checkFunction(require(
|
|
1382
|
+
result = checkFunction(require(location));
|
|
1179
1383
|
}
|
|
1180
1384
|
catch {
|
|
1181
1385
|
}
|
|
@@ -1238,7 +1442,7 @@ class Module extends EventEmitter {
|
|
|
1238
1442
|
if (cacheKey === 'throws') {
|
|
1239
1443
|
throw new Error("Not able to cache");
|
|
1240
1444
|
}
|
|
1241
|
-
return cacheKey ?
|
|
1445
|
+
return cacheKey ? crypto.randomUUID() : '';
|
|
1242
1446
|
}
|
|
1243
1447
|
static asHash(data, algorithm, digest) {
|
|
1244
1448
|
if (!algorithm && !digest) {
|
|
@@ -1303,7 +1507,7 @@ class Module extends EventEmitter {
|
|
|
1303
1507
|
chunks.push(seg);
|
|
1304
1508
|
length += seg.length;
|
|
1305
1509
|
}
|
|
1306
|
-
if (chunks.length) {
|
|
1510
|
+
if (chunks.length > 0) {
|
|
1307
1511
|
hash.update(Buffer.concat(chunks));
|
|
1308
1512
|
}
|
|
1309
1513
|
return hash.digest(digest || "hex");
|
|
@@ -1335,8 +1539,11 @@ class Module extends EventEmitter {
|
|
|
1335
1539
|
return filename || '';
|
|
1336
1540
|
}
|
|
1337
1541
|
static isURL(value, ...exclude) {
|
|
1338
|
-
|
|
1339
|
-
|
|
1542
|
+
if (exclude.length === 0 && SUPPORTED_CANPARSE) {
|
|
1543
|
+
return URL.canParse(value);
|
|
1544
|
+
}
|
|
1545
|
+
const match = REGEXP_PROTOCOL.exec(value);
|
|
1546
|
+
return !!match && !exclude.includes(match[1].toLowerCase());
|
|
1340
1547
|
}
|
|
1341
1548
|
static isFile(value, type) {
|
|
1342
1549
|
if (!type) {
|
|
@@ -1402,9 +1609,10 @@ class Module extends EventEmitter {
|
|
|
1402
1609
|
if (!type) {
|
|
1403
1610
|
return fs.existsSync(value);
|
|
1404
1611
|
}
|
|
1612
|
+
if (type === true) {
|
|
1613
|
+
return fs.statSync(value).isFile();
|
|
1614
|
+
}
|
|
1405
1615
|
switch (type) {
|
|
1406
|
-
case true:
|
|
1407
|
-
return fs.statSync(value).isFile();
|
|
1408
1616
|
case 'unc-exists':
|
|
1409
1617
|
if (!fs.existsSync(value)) {
|
|
1410
1618
|
return false;
|
|
@@ -1427,7 +1635,7 @@ class Module extends EventEmitter {
|
|
|
1427
1635
|
static resolveFile(value) {
|
|
1428
1636
|
if (isFileURL(value = value instanceof URL ? value.toString() : value.trim())) {
|
|
1429
1637
|
try {
|
|
1430
|
-
return
|
|
1638
|
+
return (0, url_1.fileURLToPath)(value);
|
|
1431
1639
|
}
|
|
1432
1640
|
catch {
|
|
1433
1641
|
}
|
|
@@ -1441,7 +1649,7 @@ class Module extends EventEmitter {
|
|
|
1441
1649
|
static resolvePath(value, base) {
|
|
1442
1650
|
try {
|
|
1443
1651
|
if (this.isURL(value = value.trim())) {
|
|
1444
|
-
return isFileURL(value) ?
|
|
1652
|
+
return isFileURL(value) ? (0, url_1.fileURLToPath)(value) : new URL(value).href;
|
|
1445
1653
|
}
|
|
1446
1654
|
if (base instanceof URL || this.isURL(base)) {
|
|
1447
1655
|
return new URL(value, base).href;
|
|
@@ -1468,13 +1676,13 @@ class Module extends EventEmitter {
|
|
|
1468
1676
|
return result;
|
|
1469
1677
|
}
|
|
1470
1678
|
static normalizePath(value, flags = 0) {
|
|
1679
|
+
if (typeof flags === 'boolean') {
|
|
1680
|
+
flags = flags ? 2 : 0;
|
|
1681
|
+
}
|
|
1471
1682
|
if (typeof value === 'string') {
|
|
1472
|
-
if (typeof flags === 'boolean') {
|
|
1473
|
-
flags = flags ? 2 : 0;
|
|
1474
|
-
}
|
|
1475
1683
|
let result = value.trim();
|
|
1476
1684
|
result = flags & 1 ? path.resolve(result) : path.normalize(result);
|
|
1477
|
-
if ((flags &
|
|
1685
|
+
if ((flags & 2) && result.length > 0) {
|
|
1478
1686
|
result = ensureDir(result);
|
|
1479
1687
|
}
|
|
1480
1688
|
return (flags & 4) && PLATFORM_WIN32 ? this.toPosix(result) : result;
|
|
@@ -1513,7 +1721,7 @@ class Module extends EventEmitter {
|
|
|
1513
1721
|
fs.unlinkSync(outDir);
|
|
1514
1722
|
}
|
|
1515
1723
|
catch {
|
|
1516
|
-
this.formatMessage(32,
|
|
1724
|
+
this.formatMessage(32, "WARN!", "Unable to overwrite file", value, { ...this.LOG_STYLE_WARN });
|
|
1517
1725
|
return false;
|
|
1518
1726
|
}
|
|
1519
1727
|
}
|
|
@@ -1544,10 +1752,10 @@ class Module extends EventEmitter {
|
|
|
1544
1752
|
empty = true;
|
|
1545
1753
|
}
|
|
1546
1754
|
if (this.isDir(outDir)) {
|
|
1547
|
-
return tryRemoveDir(outDir, empty,
|
|
1755
|
+
return tryRemoveDir(outDir, empty, recursive).length === 0;
|
|
1548
1756
|
}
|
|
1549
1757
|
if (!fs.existsSync(outDir)) {
|
|
1550
|
-
if (empty
|
|
1758
|
+
if (empty === true) {
|
|
1551
1759
|
this.createDir(outDir);
|
|
1552
1760
|
}
|
|
1553
1761
|
return true;
|
|
@@ -1560,11 +1768,11 @@ class Module extends EventEmitter {
|
|
|
1560
1768
|
}
|
|
1561
1769
|
static async copyDir(src, dest, move, recursive = true) {
|
|
1562
1770
|
const srcOut = sanitizePath(asFile(src));
|
|
1563
|
-
if (!srcOut
|
|
1771
|
+
if (!(srcOut && this.isDir(srcOut))) {
|
|
1564
1772
|
return Promise.reject(errorDirectory(asFile(src) || "Unknown"));
|
|
1565
1773
|
}
|
|
1566
1774
|
const destOut = sanitizePath(asFile(dest));
|
|
1567
|
-
if (!destOut
|
|
1775
|
+
if (!(destOut && this.createDir(destOut))) {
|
|
1568
1776
|
return Promise.reject(errorDirectory(asFile(dest) || "Unknown"));
|
|
1569
1777
|
}
|
|
1570
1778
|
let symFile, symDir, ignoreFile, ignoreDir, silent, overwrite;
|
|
@@ -1589,7 +1797,11 @@ class Module extends EventEmitter {
|
|
|
1589
1797
|
const name = file.name;
|
|
1590
1798
|
const destPath = path.join(destDir, name);
|
|
1591
1799
|
let srcPath = path.join(srcDir, name), isDir = false, isFile = file.isFile() ? 1 : 0;
|
|
1592
|
-
const ignore = () =>
|
|
1800
|
+
const ignore = () => {
|
|
1801
|
+
if (!ignored.includes(srcPath)) {
|
|
1802
|
+
ignored.push(srcPath);
|
|
1803
|
+
}
|
|
1804
|
+
};
|
|
1593
1805
|
if (file.isSymbolicLink()) {
|
|
1594
1806
|
const previous = symFound.includes(srcPath);
|
|
1595
1807
|
symFound.push(srcPath);
|
|
@@ -1598,35 +1810,41 @@ class Module extends EventEmitter {
|
|
|
1598
1810
|
const stat = fs.statSync(realPath);
|
|
1599
1811
|
if (stat.isFile()) {
|
|
1600
1812
|
if (symFile === false || !(fs.existsSync(destPath) && !fs.statSync(destPath).isFile())) {
|
|
1601
|
-
|
|
1813
|
+
ignore();
|
|
1814
|
+
return;
|
|
1602
1815
|
}
|
|
1603
1816
|
srcPath = realPath;
|
|
1604
1817
|
isFile = 2;
|
|
1605
1818
|
}
|
|
1606
1819
|
else {
|
|
1607
1820
|
if (symDir !== true || previous || !stat.isDirectory()) {
|
|
1608
|
-
|
|
1821
|
+
ignore();
|
|
1822
|
+
return;
|
|
1609
1823
|
}
|
|
1610
1824
|
isFile = 0;
|
|
1611
1825
|
isDir = true;
|
|
1612
1826
|
}
|
|
1613
1827
|
}
|
|
1614
1828
|
catch {
|
|
1615
|
-
|
|
1829
|
+
ignore();
|
|
1830
|
+
return;
|
|
1616
1831
|
}
|
|
1617
1832
|
}
|
|
1618
1833
|
if (isFile) {
|
|
1619
1834
|
if (ignoreFile?.test(name)) {
|
|
1620
|
-
|
|
1835
|
+
ignore();
|
|
1836
|
+
return;
|
|
1621
1837
|
}
|
|
1622
1838
|
if (overwrite === false) {
|
|
1623
1839
|
try {
|
|
1624
1840
|
if (fs.existsSync(destPath)) {
|
|
1625
|
-
|
|
1841
|
+
ignore();
|
|
1842
|
+
return;
|
|
1626
1843
|
}
|
|
1627
1844
|
}
|
|
1628
1845
|
catch {
|
|
1629
|
-
|
|
1846
|
+
ignore();
|
|
1847
|
+
return;
|
|
1630
1848
|
}
|
|
1631
1849
|
}
|
|
1632
1850
|
tasks.push(fs.promises[isFile === 2 ? 'copyFile' : methodName](srcPath, destPath)
|
|
@@ -1642,7 +1860,8 @@ class Module extends EventEmitter {
|
|
|
1642
1860
|
}
|
|
1643
1861
|
else if (depth > 0 && (isDir || file.isDirectory())) {
|
|
1644
1862
|
if (ignoreDir?.test(name)) {
|
|
1645
|
-
|
|
1863
|
+
ignore();
|
|
1864
|
+
return;
|
|
1646
1865
|
}
|
|
1647
1866
|
recurse.call(this, paths.concat(name), depth - 1);
|
|
1648
1867
|
}
|
|
@@ -1659,7 +1878,7 @@ class Module extends EventEmitter {
|
|
|
1659
1878
|
failed.push(srcDir);
|
|
1660
1879
|
}
|
|
1661
1880
|
}).call(this, [], !recursive ? 0 : typeof recursive === 'number' ? recursive : Infinity);
|
|
1662
|
-
Promise.all(tasks).then(() => {
|
|
1881
|
+
void Promise.all(tasks).then(() => {
|
|
1663
1882
|
if (move) {
|
|
1664
1883
|
const remaining = failed.slice(0);
|
|
1665
1884
|
for (const sym of symFound) {
|
|
@@ -1703,7 +1922,7 @@ class Module extends EventEmitter {
|
|
|
1703
1922
|
}
|
|
1704
1923
|
catch (error) {
|
|
1705
1924
|
if (copied) {
|
|
1706
|
-
this.formatMessage(32,
|
|
1925
|
+
this.formatMessage(32, "WARN!", ["Unable to delete file", path.basename(src instanceof URL ? (0, url_1.fileURLToPath)(src) : src)], error, { ...this.LOG_STYLE_WARN });
|
|
1707
1926
|
throws = false;
|
|
1708
1927
|
}
|
|
1709
1928
|
}
|
|
@@ -1811,7 +2030,8 @@ class Module extends EventEmitter {
|
|
|
1811
2030
|
return (minStreamSize !== undefined ? Promise.resolve(null) : null);
|
|
1812
2031
|
}
|
|
1813
2032
|
static async resolveMime(data) {
|
|
1814
|
-
|
|
2033
|
+
FILETYPE_ESM || (FILETYPE_ESM = await (0, types_1.importESM)('file-type'));
|
|
2034
|
+
return typeof data === 'string' ? FILETYPE_ESM.fileTypeFromFile(data) : data instanceof stream.Readable ? FILETYPE_ESM.fileTypeFromStream(data) : FILETYPE_ESM.fileTypeFromBuffer(data);
|
|
1815
2035
|
}
|
|
1816
2036
|
static lookupMime(value, extension) {
|
|
1817
2037
|
return (extension ? mime.extension(value) : mime.lookup(value)) || '';
|
|
@@ -1856,18 +2076,18 @@ class Module extends EventEmitter {
|
|
|
1856
2076
|
result += usage[name];
|
|
1857
2077
|
}
|
|
1858
2078
|
}
|
|
1859
|
-
if (typeof format === 'string') {
|
|
2079
|
+
if (typeof format === 'string' && format !== '%') {
|
|
1860
2080
|
const unit = format.toUpperCase();
|
|
1861
2081
|
switch (unit) {
|
|
1862
2082
|
case 'B':
|
|
1863
2083
|
case 'KB':
|
|
1864
|
-
return (0, types_1.formatSize)(result, { unit, decimalPlaces: 0 });
|
|
1865
|
-
case 'MB':
|
|
1866
|
-
return (0, types_1.formatSize)(result, { unit, decimalPlaces: 1 });
|
|
2084
|
+
return (0, types_1.formatSize)(result, { unit, decimalPlaces: 0, unitSeparator: ' ' });
|
|
1867
2085
|
case 'GB':
|
|
1868
2086
|
case 'TB':
|
|
1869
2087
|
case 'PB':
|
|
1870
|
-
return (0, types_1.formatSize)(result, { unit });
|
|
2088
|
+
return (0, types_1.formatSize)(result, { unit, fixedDecimals: true, decimalPlaces: 2, unitSeparator: ' ' });
|
|
2089
|
+
default:
|
|
2090
|
+
return (0, types_1.formatSize)(result, { unit: 'MB', fixedDecimals: true, decimalPlaces: 1, unitSeparator: ' ' });
|
|
1871
2091
|
}
|
|
1872
2092
|
}
|
|
1873
2093
|
return format ? formatPercent(result / MEM_TOTAL, 3) : result;
|
|
@@ -1902,16 +2122,17 @@ class Module extends EventEmitter {
|
|
|
1902
2122
|
const unit = Math.max(bar, 10);
|
|
1903
2123
|
const length = Math.floor(usage * unit);
|
|
1904
2124
|
const hint = usage === 1 ? "MAX" : usage < 0 ? "N/A" : formatPercent(usage, 2).padStart(3);
|
|
1905
|
-
result += chalk[usage >= red ?
|
|
2125
|
+
result += chalk[usage >= red ? LOG_CPUBARCOLOR[2] : usage >= yellow ? LOG_CPUBARCOLOR[1] : LOG_CPUBARCOLOR[0]].white(':'.repeat(length)) + chalk.bgGrey.white(':'.repeat(unit - length)) + (hint ? chalk.bgWhite.grey(` ${hint} `) : '');
|
|
1906
2126
|
}
|
|
1907
2127
|
else if (usage) {
|
|
1908
2128
|
result += usage + ' CPU' + (!cpu_single_core ? '/' + CPU_CORETOTAL : '');
|
|
1909
2129
|
}
|
|
1910
2130
|
}
|
|
1911
2131
|
if (mem || all) {
|
|
1912
|
-
const
|
|
2132
|
+
const format = mem_format || '%';
|
|
2133
|
+
const usage = this.getMemUsage(format);
|
|
1913
2134
|
if (usage) {
|
|
1914
|
-
result += (result ? ' ' : '') + usage
|
|
2135
|
+
result += (result ? ' ' : '') + usage + (format === '%' ? ' MEM' : '');
|
|
1915
2136
|
}
|
|
1916
2137
|
}
|
|
1917
2138
|
return result;
|
|
@@ -1958,54 +2179,14 @@ class Module extends EventEmitter {
|
|
|
1958
2179
|
catch {
|
|
1959
2180
|
}
|
|
1960
2181
|
}
|
|
1961
|
-
const latest = (result) => {
|
|
1962
|
-
if (result.length > 1) {
|
|
1963
|
-
result.sort((a, b) => {
|
|
1964
|
-
const c = a.split('.');
|
|
1965
|
-
const d = b.split('.');
|
|
1966
|
-
if (!unstable) {
|
|
1967
|
-
const g = c.some(e => isNaN(+e));
|
|
1968
|
-
const h = d.some(f => isNaN(+f));
|
|
1969
|
-
if (g && !h) {
|
|
1970
|
-
return 1;
|
|
1971
|
-
}
|
|
1972
|
-
if (h && !g) {
|
|
1973
|
-
return -1;
|
|
1974
|
-
}
|
|
1975
|
-
}
|
|
1976
|
-
return (function recurse() {
|
|
1977
|
-
const e = c.shift();
|
|
1978
|
-
const f = d.shift();
|
|
1979
|
-
if (!e || !f) {
|
|
1980
|
-
return 0;
|
|
1981
|
-
}
|
|
1982
|
-
if (e !== f) {
|
|
1983
|
-
const g = parseInt(f) - parseInt(e);
|
|
1984
|
-
if (g === 0) {
|
|
1985
|
-
if (isNaN(+e) && !isNaN(+f)) {
|
|
1986
|
-
return 1;
|
|
1987
|
-
}
|
|
1988
|
-
if (isNaN(+f) && !isNaN(+e)) {
|
|
1989
|
-
return -1;
|
|
1990
|
-
}
|
|
1991
|
-
return e < f ? 1 : -1;
|
|
1992
|
-
}
|
|
1993
|
-
return g;
|
|
1994
|
-
}
|
|
1995
|
-
return recurse();
|
|
1996
|
-
})();
|
|
1997
|
-
});
|
|
1998
|
-
}
|
|
1999
|
-
return result[0];
|
|
2000
|
-
};
|
|
2001
2182
|
if (setPnpmVer()) {
|
|
2002
2183
|
if ((0, types_1.isObject)(PNPM_VER)) {
|
|
2003
2184
|
if (startDir && !baseDir) {
|
|
2004
2185
|
return this.getPackageVersion(value, unstable, startDir, PNPM_VER.baseDir || path.join(PROCESS_CWD, 'node_modules/.pnpm'));
|
|
2005
2186
|
}
|
|
2006
2187
|
const result = PNPM_VER.items.filter(item => item[0] === value).map(item => item[1]);
|
|
2007
|
-
if (result.length) {
|
|
2008
|
-
return
|
|
2188
|
+
if (result.length > 0) {
|
|
2189
|
+
return getLatestRelease(result, unstable);
|
|
2009
2190
|
}
|
|
2010
2191
|
}
|
|
2011
2192
|
}
|
|
@@ -2020,31 +2201,22 @@ class Module extends EventEmitter {
|
|
|
2020
2201
|
if (rootPackage) {
|
|
2021
2202
|
treeRoots = treeRoots.filter(item => item.name === rootPackage);
|
|
2022
2203
|
}
|
|
2023
|
-
const getVersion = (item) => {
|
|
2024
|
-
const dependency = item.packageDependencies.get(value);
|
|
2025
|
-
if (typeof dependency === 'string') {
|
|
2026
|
-
const pkg = dependency.split('npm:');
|
|
2027
|
-
if (pkg.length > 1) {
|
|
2028
|
-
return pkg.pop();
|
|
2029
|
-
}
|
|
2030
|
-
}
|
|
2031
|
-
};
|
|
2032
2204
|
for (const folder of folders) {
|
|
2033
2205
|
for (const locator of treeRoots) {
|
|
2034
2206
|
const item = YARN_VER.getPackageInformation(locator);
|
|
2035
|
-
if (item && !item.discardFromLookup && (PLATFORM_WIN32 ? item.packageLocation.toLowerCase() : item.packageLocation) === folder && (version =
|
|
2207
|
+
if (item && !item.discardFromLookup && (PLATFORM_WIN32 ? item.packageLocation.toLowerCase() : item.packageLocation) === folder && (version = getYarnVersion(item, value))) {
|
|
2036
2208
|
return version;
|
|
2037
2209
|
}
|
|
2038
2210
|
}
|
|
2039
2211
|
}
|
|
2040
2212
|
for (const locator of treeRoots) {
|
|
2041
2213
|
const item = YARN_VER.getPackageInformation(locator);
|
|
2042
|
-
if (item && !item.discardFromLookup && (version =
|
|
2214
|
+
if (item && !item.discardFromLookup && (version = getYarnVersion(item, value))) {
|
|
2043
2215
|
result.push(version);
|
|
2044
2216
|
}
|
|
2045
2217
|
}
|
|
2046
|
-
if (result.length) {
|
|
2047
|
-
return
|
|
2218
|
+
if (result.length > 0) {
|
|
2219
|
+
return getLatestRelease(result, unstable);
|
|
2048
2220
|
}
|
|
2049
2221
|
}
|
|
2050
2222
|
catch {
|
|
@@ -2103,18 +2275,16 @@ class Module extends EventEmitter {
|
|
|
2103
2275
|
}
|
|
2104
2276
|
static sanitizeCmd(value) {
|
|
2105
2277
|
if (value.includes(' ')) {
|
|
2106
|
-
return PLATFORM_WIN32 ? wrapQuote(value) : value.
|
|
2278
|
+
return PLATFORM_WIN32 ? wrapQuote(value) : value.replaceAll(' ', '\\ ');
|
|
2107
2279
|
}
|
|
2108
2280
|
return value;
|
|
2109
2281
|
}
|
|
2110
2282
|
static sanitizeArgs(values, doubleQuote) {
|
|
2111
2283
|
const result = typeof values === 'string' ? [values] : values;
|
|
2112
|
-
const pattern = /[^0-9a-z%+-./:=@_]/gi;
|
|
2113
|
-
const sanitize = (value) => value.replace(pattern, capture => (capture === '$' || capture === '`' ? '\\' : '') + '\\' + capture);
|
|
2114
2284
|
for (let i = 0; i < result.length; ++i) {
|
|
2115
2285
|
let value = result[i].trim(), leading = '';
|
|
2116
2286
|
if (value !== '--') {
|
|
2117
|
-
const opt =
|
|
2287
|
+
const opt = REGEXP_CLIOPTION.exec(value);
|
|
2118
2288
|
if (opt) {
|
|
2119
2289
|
if (!opt[2] && !opt[3]) {
|
|
2120
2290
|
result[i] = opt[1];
|
|
@@ -2147,12 +2317,12 @@ class Module extends EventEmitter {
|
|
|
2147
2317
|
value = quoted[2];
|
|
2148
2318
|
type = true;
|
|
2149
2319
|
}
|
|
2150
|
-
if (
|
|
2320
|
+
if (REGEXP_CLIESCAPE.test(value)) {
|
|
2151
2321
|
if (type) {
|
|
2152
|
-
value = '"' +
|
|
2322
|
+
value = '"' + escapeArg(value) + '"';
|
|
2153
2323
|
}
|
|
2154
2324
|
else {
|
|
2155
|
-
value = "'" + value.
|
|
2325
|
+
value = "'" + value.replaceAll("'", "'\\''") + "'";
|
|
2156
2326
|
}
|
|
2157
2327
|
}
|
|
2158
2328
|
else if (RESERVED_SHELL.includes(value)) {
|
|
@@ -2163,7 +2333,7 @@ class Module extends EventEmitter {
|
|
|
2163
2333
|
else if (opt) {
|
|
2164
2334
|
leading = leading.trim();
|
|
2165
2335
|
if (!PLATFORM_WIN32 && leading.length > 2 && leading[1] !== '-') {
|
|
2166
|
-
leading =
|
|
2336
|
+
leading = escapeArg(leading);
|
|
2167
2337
|
}
|
|
2168
2338
|
}
|
|
2169
2339
|
}
|
|
@@ -2176,9 +2346,9 @@ class Module extends EventEmitter {
|
|
|
2176
2346
|
limit = 0;
|
|
2177
2347
|
}
|
|
2178
2348
|
let result = 0;
|
|
2179
|
-
if (limit === 0 || limit >=
|
|
2349
|
+
if (limit === 0 || limit >= getCacheTotal()) {
|
|
2180
2350
|
if (percent >= 1) {
|
|
2181
|
-
result
|
|
2351
|
+
result = getCacheTotal();
|
|
2182
2352
|
CACHE_READTEXT.clear();
|
|
2183
2353
|
CACHE_READBUFFER.clear();
|
|
2184
2354
|
CACHE_READCJS.clear();
|
|
@@ -2186,7 +2356,6 @@ class Module extends EventEmitter {
|
|
|
2186
2356
|
CACHE_CPU = new WeakMap();
|
|
2187
2357
|
CACHE_CPUHOST = new WeakMap();
|
|
2188
2358
|
(0, types_1.purgeMemory)();
|
|
2189
|
-
CACHE_TOTAL = 0;
|
|
2190
2359
|
PNPM_VER = undefined;
|
|
2191
2360
|
YARN_VER = undefined;
|
|
2192
2361
|
}
|
|
@@ -2209,7 +2378,6 @@ class Module extends EventEmitter {
|
|
|
2209
2378
|
const [map, key] = stored[i];
|
|
2210
2379
|
map.delete(key);
|
|
2211
2380
|
}
|
|
2212
|
-
CACHE_TOTAL = stored.length - result;
|
|
2213
2381
|
}
|
|
2214
2382
|
}
|
|
2215
2383
|
return result;
|
|
@@ -2241,12 +2409,12 @@ class Module extends EventEmitter {
|
|
|
2241
2409
|
}
|
|
2242
2410
|
}
|
|
2243
2411
|
else if ((0, types_1.isString)(password)) {
|
|
2244
|
-
VALUES["process.password"] = encryptMessage(password, settings.process?.cipher);
|
|
2412
|
+
VALUES["process.password"] = encryptMessage(password, settings.process?.cipher, null);
|
|
2245
2413
|
}
|
|
2246
2414
|
const { temp, node, permission, memory, error, logger } = settings;
|
|
2247
|
-
if (
|
|
2415
|
+
if (node) {
|
|
2248
2416
|
const { process: proc, require: req } = node;
|
|
2249
|
-
if (
|
|
2417
|
+
if (proc) {
|
|
2250
2418
|
const { cpu_usage, memory_usage, inline } = proc;
|
|
2251
2419
|
if (typeof cpu_usage === 'boolean') {
|
|
2252
2420
|
VALUES["node.process.cpu_usage"] = cpu_usage;
|
|
@@ -2258,7 +2426,7 @@ class Module extends EventEmitter {
|
|
|
2258
2426
|
VALUES["node.process.inline"] = inline;
|
|
2259
2427
|
}
|
|
2260
2428
|
}
|
|
2261
|
-
if (
|
|
2429
|
+
if (req) {
|
|
2262
2430
|
const { ext, npm, inline } = req;
|
|
2263
2431
|
if (!ext) {
|
|
2264
2432
|
VALUES["node.require.ext"] = '';
|
|
@@ -2268,7 +2436,7 @@ class Module extends EventEmitter {
|
|
|
2268
2436
|
}
|
|
2269
2437
|
else if (Array.isArray(ext)) {
|
|
2270
2438
|
const items = ext.map(value => (0, types_1.isString)(value) ? value.trim().toLowerCase() : '').filter(value => value);
|
|
2271
|
-
VALUES["node.require.ext"] = items.length ? items : '';
|
|
2439
|
+
VALUES["node.require.ext"] = items.length > 0 ? items : '';
|
|
2272
2440
|
}
|
|
2273
2441
|
else {
|
|
2274
2442
|
VALUES["node.require.ext"] = 'cjs';
|
|
@@ -2281,16 +2449,16 @@ class Module extends EventEmitter {
|
|
|
2281
2449
|
}
|
|
2282
2450
|
}
|
|
2283
2451
|
}
|
|
2284
|
-
if (
|
|
2452
|
+
if (settings.process) {
|
|
2285
2453
|
const { env, cipher, password: pwd } = settings.process;
|
|
2286
2454
|
if (env && typeof env.apply === 'boolean') {
|
|
2287
2455
|
VALUES["process.env.apply"] = env.apply;
|
|
2288
2456
|
}
|
|
2289
2457
|
if ((0, types_1.isString)(pwd)) {
|
|
2290
|
-
VALUES[_h = "process.password"] || (VALUES[_h] = encryptMessage(pwd, cipher));
|
|
2458
|
+
VALUES[_h = "process.password"] || (VALUES[_h] = encryptMessage(pwd, cipher, null));
|
|
2291
2459
|
}
|
|
2292
2460
|
}
|
|
2293
|
-
if (
|
|
2461
|
+
if (memory?.settings) {
|
|
2294
2462
|
const { users, cache_disk } = memory.settings;
|
|
2295
2463
|
if (typeof users === 'boolean' || Array.isArray(users)) {
|
|
2296
2464
|
VALUES["memory.settings.users"] = users;
|
|
@@ -2329,7 +2497,7 @@ class Module extends EventEmitter {
|
|
|
2329
2497
|
}
|
|
2330
2498
|
}
|
|
2331
2499
|
}
|
|
2332
|
-
if (
|
|
2500
|
+
if (logger) {
|
|
2333
2501
|
const { enabled, level, production, broadcast, stack_trace } = logger;
|
|
2334
2502
|
if (typeof enabled === 'boolean') {
|
|
2335
2503
|
SETTINGS.enabled = enabled;
|
|
@@ -2354,6 +2522,9 @@ class Module extends EventEmitter {
|
|
|
2354
2522
|
for (let name in target) {
|
|
2355
2523
|
const value = target[name];
|
|
2356
2524
|
switch (name) {
|
|
2525
|
+
case 'alt_color':
|
|
2526
|
+
name = 'altColor';
|
|
2527
|
+
break;
|
|
2357
2528
|
case 'bg_color':
|
|
2358
2529
|
name = 'bgColor';
|
|
2359
2530
|
break;
|
|
@@ -2375,6 +2546,7 @@ class Module extends EventEmitter {
|
|
|
2375
2546
|
}
|
|
2376
2547
|
break;
|
|
2377
2548
|
case 'color':
|
|
2549
|
+
case 'altColor':
|
|
2378
2550
|
case 'bgColor':
|
|
2379
2551
|
case 'bgAltColor':
|
|
2380
2552
|
case 'justify':
|
|
@@ -2394,6 +2566,22 @@ class Module extends EventEmitter {
|
|
|
2394
2566
|
Object.assign(stored[name], data);
|
|
2395
2567
|
}
|
|
2396
2568
|
break;
|
|
2569
|
+
case 'braces':
|
|
2570
|
+
switch (section) {
|
|
2571
|
+
case 'title':
|
|
2572
|
+
if ((0, types_1.isString)(value) && value.length === 1) {
|
|
2573
|
+
stored[name] = value;
|
|
2574
|
+
}
|
|
2575
|
+
break;
|
|
2576
|
+
case 'hint':
|
|
2577
|
+
case 'message':
|
|
2578
|
+
case 'error':
|
|
2579
|
+
if (Array.isArray(value) && value.length === 2 && value.every(ch => typeof ch === 'string')) {
|
|
2580
|
+
stored[name] = value;
|
|
2581
|
+
}
|
|
2582
|
+
break;
|
|
2583
|
+
}
|
|
2584
|
+
break;
|
|
2397
2585
|
}
|
|
2398
2586
|
}
|
|
2399
2587
|
}
|
|
@@ -2436,7 +2624,7 @@ class Module extends EventEmitter {
|
|
|
2436
2624
|
else if (session_id === true) {
|
|
2437
2625
|
SETTINGS.session_id = 3;
|
|
2438
2626
|
}
|
|
2439
|
-
else if ((session_id = +session_id) > 0) {
|
|
2627
|
+
else if ((session_id = +session_id | 0) > 0) {
|
|
2440
2628
|
SETTINGS.session_id = session_id;
|
|
2441
2629
|
}
|
|
2442
2630
|
}
|
|
@@ -2446,9 +2634,19 @@ class Module extends EventEmitter {
|
|
|
2446
2634
|
const process = logger.process;
|
|
2447
2635
|
if (process) {
|
|
2448
2636
|
if (!(0, types_1.isObject)(SETTINGS.process)) {
|
|
2449
|
-
SETTINGS.process = {
|
|
2637
|
+
SETTINGS.process = { ...SETTINGS_PROCESS };
|
|
2638
|
+
copyBarColor(SETTINGS.process.cpu_bar_color);
|
|
2450
2639
|
}
|
|
2451
2640
|
if ((0, types_1.isObject)(process)) {
|
|
2641
|
+
if ('cpu_bar_color' in process) {
|
|
2642
|
+
const barColor = process.cpu_bar_color;
|
|
2643
|
+
if (Array.isArray(barColor) && barColor.length === 3 && barColor.every(color => isBackgroundColor(color))) {
|
|
2644
|
+
copyBarColor(barColor);
|
|
2645
|
+
}
|
|
2646
|
+
else {
|
|
2647
|
+
delete process.cpu_bar_color;
|
|
2648
|
+
}
|
|
2649
|
+
}
|
|
2452
2650
|
Object.assign(SETTINGS.process, process);
|
|
2453
2651
|
}
|
|
2454
2652
|
else {
|
|
@@ -2475,8 +2673,9 @@ class Module extends EventEmitter {
|
|
|
2475
2673
|
if (stack_trace && stack_trace !== true && +stack_trace > 0) {
|
|
2476
2674
|
Error.stackTraceLimit = +stack_trace;
|
|
2477
2675
|
}
|
|
2676
|
+
setLogMinWidth();
|
|
2478
2677
|
}
|
|
2479
|
-
if (
|
|
2678
|
+
if (error) {
|
|
2480
2679
|
if (error.out) {
|
|
2481
2680
|
VALUES["error.out"] = this.parseFunction(error.out, { external: true, absolute: true });
|
|
2482
2681
|
}
|
|
@@ -2505,44 +2704,52 @@ class Module extends EventEmitter {
|
|
|
2505
2704
|
});
|
|
2506
2705
|
}
|
|
2507
2706
|
}
|
|
2508
|
-
let dir = settings.temp_dir, write, modified;
|
|
2707
|
+
let dir = settings.temp_dir, env, write, modified;
|
|
2509
2708
|
if ((0, types_1.isPlainObject)(temp)) {
|
|
2510
2709
|
dir || (dir = temp.dir);
|
|
2710
|
+
if (temp.env) {
|
|
2711
|
+
env = process.env[temp.env];
|
|
2712
|
+
}
|
|
2511
2713
|
write = temp.write;
|
|
2512
2714
|
}
|
|
2513
|
-
if (
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
this.formatMessage(1, 'WARN', 'Temp directory can only be relative', dir, { ...this.LOG_STYLE_WARN, newline: true });
|
|
2519
|
-
dir = undefined;
|
|
2520
|
-
}
|
|
2715
|
+
if (env && path.isAbsolute(env) && this.isDir(env)) {
|
|
2716
|
+
(0, types_1.setTempDir)(TEMP_DIR = stripPath(env));
|
|
2717
|
+
dir = path.relative(PROCESS_CWD, TEMP_DIR);
|
|
2718
|
+
VALUES["temp.dir"] = dir;
|
|
2719
|
+
modified = true;
|
|
2521
2720
|
}
|
|
2522
|
-
if (
|
|
2523
|
-
dir =
|
|
2721
|
+
else if ((0, types_1.isString)(dir)) {
|
|
2722
|
+
if (path.isAbsolute(dir = stripPath(dir))) {
|
|
2723
|
+
if (withinDir(dir, PROCESS_CWD)) {
|
|
2724
|
+
dir = dir.substring(ensureDir(PROCESS_CWD).length);
|
|
2725
|
+
}
|
|
2726
|
+
else {
|
|
2727
|
+
this.formatMessage(1, "WARN!", 'Temp directory can only be relative', dir, { ...this.LOG_STYLE_WARN, newline: true });
|
|
2728
|
+
dir = VALUES["temp.dir"];
|
|
2729
|
+
}
|
|
2730
|
+
}
|
|
2731
|
+
do {
|
|
2732
|
+
const [output, index] = tryIncrementDir(path.join(PROCESS_CWD, dir), 5);
|
|
2733
|
+
if ((0, types_1.isString)(output)) {
|
|
2734
|
+
if (index > 0) {
|
|
2735
|
+
dir = trimDir(dir) + '_' + index;
|
|
2736
|
+
}
|
|
2737
|
+
if (dir !== VALUES["temp.dir"]) {
|
|
2738
|
+
VALUES["temp.dir"] = dir;
|
|
2739
|
+
modified = true;
|
|
2740
|
+
}
|
|
2741
|
+
(0, types_1.setTempDir)(TEMP_DIR = output);
|
|
2742
|
+
break;
|
|
2743
|
+
}
|
|
2744
|
+
if (output instanceof Error) {
|
|
2745
|
+
this.writeFail(["Unable to create temp directory", dir], output, 32);
|
|
2746
|
+
}
|
|
2747
|
+
} while ((dir !== "tmp") && (dir = "tmp"));
|
|
2524
2748
|
}
|
|
2525
2749
|
if (typeof write === 'boolean') {
|
|
2526
|
-
modified = VALUES["temp.write"] !== write;
|
|
2750
|
+
modified || (modified = VALUES["temp.write"] !== write);
|
|
2527
2751
|
VALUES["temp.write"] = write;
|
|
2528
2752
|
}
|
|
2529
|
-
do {
|
|
2530
|
-
const [output, index] = tryIncrementDir(path.join(PROCESS_CWD, dir), 5);
|
|
2531
|
-
if ((0, types_1.isString)(output)) {
|
|
2532
|
-
if (index > 0) {
|
|
2533
|
-
dir = trimDir(dir) + '_' + index;
|
|
2534
|
-
}
|
|
2535
|
-
if (dir !== VALUES["temp.dir"]) {
|
|
2536
|
-
VALUES["temp.dir"] = dir;
|
|
2537
|
-
modified = true;
|
|
2538
|
-
}
|
|
2539
|
-
(0, types_1.setTempDir)(TEMP_DIR = output);
|
|
2540
|
-
break;
|
|
2541
|
-
}
|
|
2542
|
-
if (output instanceof Error) {
|
|
2543
|
-
this.writeFail(["Unable to create temp directory", dir], output, 32);
|
|
2544
|
-
}
|
|
2545
|
-
} while ((dir !== "tmp") && (dir = "tmp"));
|
|
2546
2753
|
if (modified) {
|
|
2547
2754
|
this.formatMessage(1, 'TEMP', ["Directory was modified", dir], TEMP_DIR + (VALUES["temp.write"] ? ' - writable' : ''), { ...this.LOG_STYLE_NOTICE, newline: true });
|
|
2548
2755
|
}
|
|
@@ -2553,7 +2760,7 @@ class Module extends EventEmitter {
|
|
|
2553
2760
|
return true;
|
|
2554
2761
|
}
|
|
2555
2762
|
supported(major, minor, patch, lts) {
|
|
2556
|
-
return
|
|
2763
|
+
return (0, types_1.supported)(major, minor, patch, lts);
|
|
2557
2764
|
}
|
|
2558
2765
|
supports(name, value) {
|
|
2559
2766
|
if (typeof value === 'boolean') {
|
|
@@ -2589,7 +2796,7 @@ class Module extends EventEmitter {
|
|
|
2589
2796
|
createDir ?? (createDir = true);
|
|
2590
2797
|
}
|
|
2591
2798
|
if (uuidDir) {
|
|
2592
|
-
leading.push(
|
|
2799
|
+
leading.push(crypto.randomUUID());
|
|
2593
2800
|
createDir ?? (createDir = true);
|
|
2594
2801
|
}
|
|
2595
2802
|
if ((createDir || increment > 0) && !Module.isDir(result = path.join(...leading))) {
|
|
@@ -2603,7 +2810,7 @@ class Module extends EventEmitter {
|
|
|
2603
2810
|
result = output;
|
|
2604
2811
|
}
|
|
2605
2812
|
if (filename) {
|
|
2606
|
-
const trailing = (filename.startsWith('.') ?
|
|
2813
|
+
const trailing = (filename.startsWith('.') ? crypto.randomUUID() : '') + filename;
|
|
2607
2814
|
if (result) {
|
|
2608
2815
|
return path.join(result, trailing);
|
|
2609
2816
|
}
|
|
@@ -2662,9 +2869,9 @@ class Module extends EventEmitter {
|
|
|
2662
2869
|
readFile(src, options = {}, callback) {
|
|
2663
2870
|
let promises, outSrc;
|
|
2664
2871
|
[options, promises, callback] = parseFileArgs(options, callback);
|
|
2665
|
-
if (outSrc = hasFileSystem
|
|
2666
|
-
let { requireExt, minStreamSize, cache } = options;
|
|
2667
|
-
|
|
2872
|
+
if (outSrc = hasFileSystem(this, 0, src, options)) {
|
|
2873
|
+
let { encoding, requireExt, minStreamSize, cache } = options;
|
|
2874
|
+
encoding && (encoding = (0, types_1.getEncoding)(encoding));
|
|
2668
2875
|
const setCache = (data, cjs) => {
|
|
2669
2876
|
if (data) {
|
|
2670
2877
|
if (cache || cache !== false && autoMemoryCache()) {
|
|
@@ -2718,7 +2925,7 @@ class Module extends EventEmitter {
|
|
|
2718
2925
|
return Promise.resolve(result);
|
|
2719
2926
|
}
|
|
2720
2927
|
return fs.promises.readFile(outSrc, encoding).then(data => {
|
|
2721
|
-
setCache(data);
|
|
2928
|
+
setCache(data, false);
|
|
2722
2929
|
return data;
|
|
2723
2930
|
});
|
|
2724
2931
|
}
|
|
@@ -2729,7 +2936,7 @@ class Module extends EventEmitter {
|
|
|
2729
2936
|
else {
|
|
2730
2937
|
fs.readFile(outSrc, encoding, (err, data) => {
|
|
2731
2938
|
if (!err) {
|
|
2732
|
-
setCache(data);
|
|
2939
|
+
setCache(data, false);
|
|
2733
2940
|
}
|
|
2734
2941
|
callback(err, data);
|
|
2735
2942
|
});
|
|
@@ -2738,7 +2945,7 @@ class Module extends EventEmitter {
|
|
|
2738
2945
|
}
|
|
2739
2946
|
try {
|
|
2740
2947
|
if (!result) {
|
|
2741
|
-
setCache(result = fs.readFileSync(outSrc, encoding));
|
|
2948
|
+
setCache(result = fs.readFileSync(outSrc, encoding), false);
|
|
2742
2949
|
}
|
|
2743
2950
|
return result;
|
|
2744
2951
|
}
|
|
@@ -2756,7 +2963,7 @@ class Module extends EventEmitter {
|
|
|
2756
2963
|
writeFile(src, data, options = {}, callback) {
|
|
2757
2964
|
let promises, outSrc;
|
|
2758
2965
|
[options, promises, callback] = parseFileArgs(options, callback);
|
|
2759
|
-
if (outSrc = hasFileSystem
|
|
2966
|
+
if (outSrc = hasFileSystem(this, 1, src, options, true, options.overwrite)) {
|
|
2760
2967
|
if (promises) {
|
|
2761
2968
|
return fs.promises.writeFile(outSrc, data, options.encoding).then(() => {
|
|
2762
2969
|
this.emit('file:write', outSrc, options);
|
|
@@ -2793,7 +3000,7 @@ class Module extends EventEmitter {
|
|
|
2793
3000
|
deleteFile(src, options = {}, callback) {
|
|
2794
3001
|
let promises, outSrc;
|
|
2795
3002
|
[options, promises, callback] = parseFileArgs(options, callback);
|
|
2796
|
-
if (outSrc = hasFileSystem
|
|
3003
|
+
if (outSrc = hasFileSystem(this, 1, src, options)) {
|
|
2797
3004
|
if (promises) {
|
|
2798
3005
|
return fs.promises.unlink(outSrc).then(() => {
|
|
2799
3006
|
this.emit('file:delete', outSrc, options);
|
|
@@ -2833,7 +3040,7 @@ class Module extends EventEmitter {
|
|
|
2833
3040
|
copyFile(src, dest, options = {}, callback) {
|
|
2834
3041
|
let promises, outSrc, outDest;
|
|
2835
3042
|
[options, promises, callback] = parseFileArgs(options, callback);
|
|
2836
|
-
if ((outSrc = hasFileSystem
|
|
3043
|
+
if ((outSrc = hasFileSystem(this, 0, src, options)) && (outDest = hasFileSystem(this, 1, dest, options, true, options.overwrite))) {
|
|
2837
3044
|
const destDir = path.dirname(outDest);
|
|
2838
3045
|
if (!Module.isDir(destDir) && (options.createDir === false || !Module.createDir(destDir))) {
|
|
2839
3046
|
if (promises) {
|
|
@@ -2886,7 +3093,7 @@ class Module extends EventEmitter {
|
|
|
2886
3093
|
moveFile(src, dest, options = {}, callback) {
|
|
2887
3094
|
let promises, outSrc, outDest;
|
|
2888
3095
|
[options, promises, callback] = parseFileArgs(options, callback);
|
|
2889
|
-
if ((outSrc = hasFileSystem
|
|
3096
|
+
if ((outSrc = hasFileSystem(this, 1, src, options)) && (outDest = hasFileSystem(this, 1, dest, options, true, options.overwrite))) {
|
|
2890
3097
|
const destDir = path.dirname(outDest);
|
|
2891
3098
|
if (!Module.isDir(destDir) && (options.createDir === false || !Module.createDir(destDir))) {
|
|
2892
3099
|
if (promises) {
|
|
@@ -2902,23 +3109,10 @@ class Module extends EventEmitter {
|
|
|
2902
3109
|
}
|
|
2903
3110
|
else {
|
|
2904
3111
|
options.outSrc = outSrc;
|
|
2905
|
-
const checkError = (err) => {
|
|
2906
|
-
if (Module.isErrorCode(err, 'EXDEV')) {
|
|
2907
|
-
try {
|
|
2908
|
-
fs.copyFileSync(outSrc, outDest);
|
|
2909
|
-
fs.unlinkSync(outSrc);
|
|
2910
|
-
return true;
|
|
2911
|
-
}
|
|
2912
|
-
catch {
|
|
2913
|
-
fs.unlink(outDest, () => { });
|
|
2914
|
-
}
|
|
2915
|
-
}
|
|
2916
|
-
return false;
|
|
2917
|
-
};
|
|
2918
3112
|
if (promises) {
|
|
2919
3113
|
return new Promise((resolve, reject) => {
|
|
2920
3114
|
fs.rename(outSrc, outDest, err => {
|
|
2921
|
-
if (err &&
|
|
3115
|
+
if (err && checkExDev(err, outSrc, outDest)) {
|
|
2922
3116
|
err = null;
|
|
2923
3117
|
}
|
|
2924
3118
|
if (!err) {
|
|
@@ -2933,7 +3127,7 @@ class Module extends EventEmitter {
|
|
|
2933
3127
|
}
|
|
2934
3128
|
if (isFunction(callback)) {
|
|
2935
3129
|
fs.rename(outSrc, outDest, err => {
|
|
2936
|
-
if (err &&
|
|
3130
|
+
if (err && checkExDev(err, outSrc, outDest)) {
|
|
2937
3131
|
err = null;
|
|
2938
3132
|
}
|
|
2939
3133
|
if (!err) {
|
|
@@ -2949,7 +3143,7 @@ class Module extends EventEmitter {
|
|
|
2949
3143
|
return true;
|
|
2950
3144
|
}
|
|
2951
3145
|
catch (err) {
|
|
2952
|
-
if (
|
|
3146
|
+
if (checkExDev(err, outSrc, outDest)) {
|
|
2953
3147
|
this.emit('file:move', outDest, options);
|
|
2954
3148
|
return true;
|
|
2955
3149
|
}
|
|
@@ -2974,7 +3168,7 @@ class Module extends EventEmitter {
|
|
|
2974
3168
|
createDir(src, options = {}, callback) {
|
|
2975
3169
|
let promises, outSrc;
|
|
2976
3170
|
[options, promises, callback] = parseFileArgs(options, callback);
|
|
2977
|
-
if (outSrc = hasFileSystem
|
|
3171
|
+
if (outSrc = hasFileSystem(this, 1, src, options, true)) {
|
|
2978
3172
|
if (Module.isDir(outSrc)) {
|
|
2979
3173
|
if (promises) {
|
|
2980
3174
|
return Promise.resolve(true);
|
|
@@ -3010,7 +3204,9 @@ class Module extends EventEmitter {
|
|
|
3010
3204
|
return success;
|
|
3011
3205
|
});
|
|
3012
3206
|
if (callback) {
|
|
3013
|
-
result.catch((err) =>
|
|
3207
|
+
result.catch((err) => {
|
|
3208
|
+
callback(errorUnknown(err, outSrc));
|
|
3209
|
+
});
|
|
3014
3210
|
}
|
|
3015
3211
|
return promises ? result : void 0;
|
|
3016
3212
|
}
|
|
@@ -3036,11 +3232,10 @@ class Module extends EventEmitter {
|
|
|
3036
3232
|
removeDir(src, options = {}, callback) {
|
|
3037
3233
|
let promises, outSrc;
|
|
3038
3234
|
[options, promises, callback] = parseFileArgs(options, callback);
|
|
3039
|
-
if (outSrc = hasFileSystem
|
|
3235
|
+
if (outSrc = hasFileSystem(this, 1, src, options, true)) {
|
|
3040
3236
|
try {
|
|
3041
3237
|
if (Module.isDir(outSrc)) {
|
|
3042
3238
|
const { emptyDir = false, recursive = true } = options;
|
|
3043
|
-
const errorResponse = (failed) => new Error("Unsupported access" + ':' + (failed.length > 1 ? failed.map(value => `\n- ${value}`) : ' ' + failed[0]));
|
|
3044
3239
|
if (promises || isFunction(callback)) {
|
|
3045
3240
|
const result = new Promise((resolve, reject) => {
|
|
3046
3241
|
const failed = tryRemoveDir(outSrc, emptyDir, !!recursive);
|
|
@@ -3048,7 +3243,7 @@ class Module extends EventEmitter {
|
|
|
3048
3243
|
resolve(true);
|
|
3049
3244
|
}
|
|
3050
3245
|
else {
|
|
3051
|
-
reject(
|
|
3246
|
+
reject(errorAccess(failed));
|
|
3052
3247
|
}
|
|
3053
3248
|
})
|
|
3054
3249
|
.then(success => {
|
|
@@ -3059,7 +3254,9 @@ class Module extends EventEmitter {
|
|
|
3059
3254
|
return success;
|
|
3060
3255
|
});
|
|
3061
3256
|
if (callback) {
|
|
3062
|
-
result.catch((err) =>
|
|
3257
|
+
result.catch((err) => {
|
|
3258
|
+
callback(errorUnknown(err, outSrc));
|
|
3259
|
+
});
|
|
3063
3260
|
}
|
|
3064
3261
|
return promises ? result : void 0;
|
|
3065
3262
|
}
|
|
@@ -3068,7 +3265,7 @@ class Module extends EventEmitter {
|
|
|
3068
3265
|
this.emit('dir:remove', outSrc, options);
|
|
3069
3266
|
return true;
|
|
3070
3267
|
}
|
|
3071
|
-
throw
|
|
3268
|
+
throw errorAccess(failed);
|
|
3072
3269
|
}
|
|
3073
3270
|
else if (fs.existsSync(outSrc)) {
|
|
3074
3271
|
if (promises) {
|
|
@@ -3144,7 +3341,7 @@ class Module extends EventEmitter {
|
|
|
3144
3341
|
: type & 2048 ? meter.image
|
|
3145
3342
|
: type & 8 ? meter.compress
|
|
3146
3343
|
: meter.process) || 250;
|
|
3147
|
-
const duration = getTimeOffset(startTime);
|
|
3344
|
+
const duration = getTimeOffset(startTime, 0);
|
|
3148
3345
|
let meterTime = duration, delayTime = options.delayTime;
|
|
3149
3346
|
if (delayTime !== undefined) {
|
|
3150
3347
|
if (Array.isArray(delayTime)) {
|
|
@@ -3170,20 +3367,20 @@ class Module extends EventEmitter {
|
|
|
3170
3367
|
(failed ? 'X' : '>').repeat(Math.min(Math.ceil(meterTime / increment), SETTINGS.format.meter.width)),
|
|
3171
3368
|
options
|
|
3172
3369
|
];
|
|
3173
|
-
|
|
3370
|
+
applySessionId(this, options);
|
|
3174
3371
|
if (statusType > 0) {
|
|
3175
3372
|
this.addLog(statusType, value, typeof startTime === 'number' ? startTime : undefined, duration);
|
|
3176
3373
|
}
|
|
3374
|
+
if (!options.bypassLog) {
|
|
3375
|
+
this.addLog(types_1.STATUS_TYPE.INFO, title + ': ' + value, Date.now(), duration);
|
|
3376
|
+
}
|
|
3177
3377
|
if (options.queue && !this._logFlushed) {
|
|
3178
3378
|
this._logQueued.push(args);
|
|
3179
3379
|
}
|
|
3180
|
-
else {
|
|
3181
|
-
setCpuAndMem
|
|
3380
|
+
else if (!this.silent) {
|
|
3381
|
+
setCpuAndMem(this, options);
|
|
3182
3382
|
relayMessage(this, args);
|
|
3183
3383
|
}
|
|
3184
|
-
if (!options.bypassLog) {
|
|
3185
|
-
this.addLog(types_1.STATUS_TYPE.INFO, title + ' -> ' + value, Date.now(), duration);
|
|
3186
|
-
}
|
|
3187
3384
|
}
|
|
3188
3385
|
writeTimeElapsed(title, value, startTime, options = {}) {
|
|
3189
3386
|
const { type = 0, statusType = 0 } = options;
|
|
@@ -3193,14 +3390,14 @@ class Module extends EventEmitter {
|
|
|
3193
3390
|
value = value[0];
|
|
3194
3391
|
}
|
|
3195
3392
|
else if (options.showCpu) {
|
|
3196
|
-
setCpuAndMem
|
|
3393
|
+
setCpuAndMem(this, options);
|
|
3197
3394
|
}
|
|
3198
3395
|
else {
|
|
3199
3396
|
message = value;
|
|
3200
3397
|
value = '';
|
|
3201
3398
|
}
|
|
3202
3399
|
value || (value = isFailed(options) ? "Failed" : "Success");
|
|
3203
|
-
const duration = getTimeOffset(startTime);
|
|
3400
|
+
const duration = getTimeOffset(startTime, 0);
|
|
3204
3401
|
const args = [
|
|
3205
3402
|
(128 | type),
|
|
3206
3403
|
title,
|
|
@@ -3208,14 +3405,14 @@ class Module extends EventEmitter {
|
|
|
3208
3405
|
message,
|
|
3209
3406
|
options
|
|
3210
3407
|
];
|
|
3211
|
-
|
|
3408
|
+
applySessionId(this, options);
|
|
3212
3409
|
if (statusType > 0) {
|
|
3213
3410
|
this.addLog(statusType, value, typeof startTime === 'number' ? startTime : undefined, duration);
|
|
3214
3411
|
}
|
|
3215
3412
|
if (options.queue && !this._logFlushed) {
|
|
3216
3413
|
this._logQueued.push(args);
|
|
3217
3414
|
}
|
|
3218
|
-
else {
|
|
3415
|
+
else if (!this.silent) {
|
|
3219
3416
|
relayMessage(this, args);
|
|
3220
3417
|
}
|
|
3221
3418
|
}
|
|
@@ -3240,14 +3437,14 @@ class Module extends EventEmitter {
|
|
|
3240
3437
|
message = null;
|
|
3241
3438
|
}
|
|
3242
3439
|
const args = [(type | 512), title, value, message, applyStyle(options, Module.LOG_STYLE_FAIL)];
|
|
3243
|
-
|
|
3440
|
+
applySessionId(this, options);
|
|
3244
3441
|
if (options.queue !== false && !options.passThrough && !this._logFlushed) {
|
|
3245
3442
|
if (VALUES["error.out"]) {
|
|
3246
3443
|
options.timeStamp = Date.now();
|
|
3247
3444
|
}
|
|
3248
3445
|
this._logQueued.push(args);
|
|
3249
3446
|
}
|
|
3250
|
-
else {
|
|
3447
|
+
else if (!this.silent) {
|
|
3251
3448
|
Module.formatMessage(...args);
|
|
3252
3449
|
}
|
|
3253
3450
|
const host = this.host;
|
|
@@ -3332,7 +3529,7 @@ class Module extends EventEmitter {
|
|
|
3332
3529
|
else {
|
|
3333
3530
|
this.addLog(options.statusType || types_1.STATUS_TYPE.ERROR, message);
|
|
3334
3531
|
}
|
|
3335
|
-
this.errors.push(message instanceof Error ?
|
|
3532
|
+
this.errors.push(message instanceof Error ? formatError(message) : message);
|
|
3336
3533
|
}
|
|
3337
3534
|
if (this.listenerCount('error') > 0) {
|
|
3338
3535
|
this.emit('error', errorObject(message));
|
|
@@ -3345,7 +3542,7 @@ class Module extends EventEmitter {
|
|
|
3345
3542
|
formatMessage(type, title, value, message, options = {}) {
|
|
3346
3543
|
const statusType = options.statusType || 0;
|
|
3347
3544
|
const args = [type, title, value, message, options];
|
|
3348
|
-
|
|
3545
|
+
applySessionId(this, options);
|
|
3349
3546
|
if (statusType > 0) {
|
|
3350
3547
|
this.addLog(statusType, message || (Array.isArray(value) ? value[0] : value));
|
|
3351
3548
|
}
|
|
@@ -3355,7 +3552,7 @@ class Module extends EventEmitter {
|
|
|
3355
3552
|
}
|
|
3356
3553
|
this._logQueued.push(args);
|
|
3357
3554
|
}
|
|
3358
|
-
else {
|
|
3555
|
+
else if (!this.silent) {
|
|
3359
3556
|
relayMessage(this, args);
|
|
3360
3557
|
}
|
|
3361
3558
|
}
|
|
@@ -3483,7 +3680,7 @@ class Module extends EventEmitter {
|
|
|
3483
3680
|
this.status.push({ type: types_1.STATUS_TYPE.TRACE, value: message ? value.stack.replace(message, '').trim() : value.stack, timeStamp, name: types_1.STATUS_TYPE[types_1.STATUS_TYPE.TRACE], duration, sessionId: this.sessionId, from: this.moduleName, source });
|
|
3484
3681
|
}
|
|
3485
3682
|
else {
|
|
3486
|
-
message =
|
|
3683
|
+
message = formatError(value);
|
|
3487
3684
|
}
|
|
3488
3685
|
}
|
|
3489
3686
|
else {
|
|
@@ -3502,18 +3699,22 @@ class Module extends EventEmitter {
|
|
|
3502
3699
|
flushLog() {
|
|
3503
3700
|
this._logFlushed = true;
|
|
3504
3701
|
const logQueued = this._logQueued;
|
|
3505
|
-
if (logQueued.length) {
|
|
3506
|
-
logQueued.sort((a, b) => b[0] - a[0])
|
|
3507
|
-
logQueued.forEach(args => {
|
|
3702
|
+
if (logQueued.length > 0) {
|
|
3703
|
+
for (const args of logQueued.sort((a, b) => b[0] - a[0])) {
|
|
3508
3704
|
if (args.length === 2) {
|
|
3509
|
-
|
|
3705
|
+
const [type, value] = args;
|
|
3706
|
+
if (this.broadcastId) {
|
|
3707
|
+
Module.formatMessage(type, '', this.supports('stripAnsi') ? stripansi(value) : value, null, applySessionId(this, { sessionId: '' }));
|
|
3708
|
+
}
|
|
3709
|
+
else {
|
|
3510
3710
|
writeLine(args[1]);
|
|
3511
|
-
|
|
3711
|
+
(0, types_1.setLogCurrent)({ type, value });
|
|
3512
3712
|
}
|
|
3513
|
-
args = [args[0], '', this.supports('stripAnsi') ? stripansi(args[1]) : args[1], null, applyLogId.call(this, { sessionId: '' })];
|
|
3514
3713
|
}
|
|
3515
|
-
|
|
3516
|
-
|
|
3714
|
+
else {
|
|
3715
|
+
relayMessage(this, args);
|
|
3716
|
+
}
|
|
3717
|
+
}
|
|
3517
3718
|
logQueued.length = 0;
|
|
3518
3719
|
}
|
|
3519
3720
|
}
|
|
@@ -3577,7 +3778,9 @@ class Module extends EventEmitter {
|
|
|
3577
3778
|
this.abortable = value.willAbort(this);
|
|
3578
3779
|
value.modules.add(this);
|
|
3579
3780
|
if (aborting) {
|
|
3580
|
-
value.signal.addEventListener('abort', this[kAbortEvent] = () =>
|
|
3781
|
+
value.signal.addEventListener('abort', this[kAbortEvent] = () => {
|
|
3782
|
+
this.abort(new Error("Aborted by host"));
|
|
3783
|
+
}, { once: true });
|
|
3581
3784
|
}
|
|
3582
3785
|
}
|
|
3583
3786
|
}
|
|
@@ -3618,6 +3821,12 @@ class Module extends EventEmitter {
|
|
|
3618
3821
|
get threadable() {
|
|
3619
3822
|
return this._threadable;
|
|
3620
3823
|
}
|
|
3824
|
+
set silent(value) {
|
|
3825
|
+
this._silent = value;
|
|
3826
|
+
}
|
|
3827
|
+
get silent() {
|
|
3828
|
+
return this._silent ?? this.host?.silent ?? false;
|
|
3829
|
+
}
|
|
3621
3830
|
get logType() {
|
|
3622
3831
|
return types_1.LOG_TYPE;
|
|
3623
3832
|
}
|
|
@@ -3666,5 +3875,5 @@ Module.LOG_STYLE_REVERSE = Object.freeze({ titleBgColor: 'bgWhite', titleColor:
|
|
|
3666
3875
|
EventEmitter.defaultMaxListeners = Infinity;
|
|
3667
3876
|
Object.freeze(types_1.LOG_TYPE);
|
|
3668
3877
|
Object.freeze(types_1.STATUS_TYPE);
|
|
3669
|
-
|
|
3878
|
+
setLogMinWidth();
|
|
3670
3879
|
module.exports = Module;
|