@e-mc/module 0.10.14 → 0.10.15
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 +6 -6
- package/index.js +19 -38
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
## Interface
|
|
11
11
|
|
|
12
|
-
* [View Source](https://www.unpkg.com/@e-mc/types@0.10.
|
|
12
|
+
* [View Source](https://www.unpkg.com/@e-mc/types@0.10.15/lib/index.d.ts)
|
|
13
13
|
|
|
14
14
|
```typescript
|
|
15
15
|
import type { LogStatus } from "./squared";
|
|
@@ -407,11 +407,11 @@ interface LoggerModule {
|
|
|
407
407
|
|
|
408
408
|
## References
|
|
409
409
|
|
|
410
|
-
- https://www.unpkg.com/@e-mc/types@0.10.
|
|
411
|
-
- https://www.unpkg.com/@e-mc/types@0.10.
|
|
412
|
-
- https://www.unpkg.com/@e-mc/types@0.10.
|
|
413
|
-
- https://www.unpkg.com/@e-mc/types@0.10.
|
|
414
|
-
- https://www.unpkg.com/@e-mc/types@0.10.
|
|
410
|
+
- https://www.unpkg.com/@e-mc/types@0.10.15/lib/core.d.ts
|
|
411
|
+
- https://www.unpkg.com/@e-mc/types@0.10.15/lib/logger.d.ts
|
|
412
|
+
- https://www.unpkg.com/@e-mc/types@0.10.15/lib/module.d.ts
|
|
413
|
+
- https://www.unpkg.com/@e-mc/types@0.10.15/lib/node.d.ts
|
|
414
|
+
- https://www.unpkg.com/@e-mc/types@0.10.15/lib/settings.d.ts
|
|
415
415
|
|
|
416
416
|
* https://www.npmjs.com/package/@types/node
|
|
417
417
|
|
package/index.js
CHANGED
|
@@ -415,14 +415,14 @@ function tryCreateDir(value) {
|
|
|
415
415
|
}
|
|
416
416
|
return false;
|
|
417
417
|
}
|
|
418
|
-
function tryRemoveDir(
|
|
418
|
+
function tryRemoveDir(srcDir, empty, recursive) {
|
|
419
419
|
const temp = typeof empty === 'number';
|
|
420
420
|
let options;
|
|
421
421
|
if (!temp) {
|
|
422
422
|
try {
|
|
423
|
-
fs.rmSync(
|
|
423
|
+
fs.rmSync(srcDir, { recursive, force: true });
|
|
424
424
|
if (empty) {
|
|
425
|
-
fs.mkdirSync(
|
|
425
|
+
fs.mkdirSync(srcDir);
|
|
426
426
|
}
|
|
427
427
|
return [];
|
|
428
428
|
}
|
|
@@ -430,30 +430,11 @@ function tryRemoveDir(value, empty, recursive) {
|
|
|
430
430
|
}
|
|
431
431
|
options = { recursive };
|
|
432
432
|
}
|
|
433
|
-
value = Module.normalizePath(value, 1);
|
|
434
433
|
const failed = [];
|
|
435
|
-
const nameMap = new WeakMap();
|
|
436
|
-
let files;
|
|
437
|
-
if (temp) {
|
|
438
|
-
files = [];
|
|
439
|
-
fs.readdirSync(value).forEach(name => {
|
|
440
|
-
try {
|
|
441
|
-
const stat = fs.statSync(value + name);
|
|
442
|
-
nameMap.set(stat, name);
|
|
443
|
-
files.push(stat);
|
|
444
|
-
}
|
|
445
|
-
catch {
|
|
446
|
-
failed.push(value + name);
|
|
447
|
-
}
|
|
448
|
-
});
|
|
449
|
-
}
|
|
450
|
-
else {
|
|
451
|
-
files = fs.readdirSync(value, { withFileTypes: true });
|
|
452
|
-
}
|
|
453
434
|
const current = Date.now();
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
const pathname =
|
|
435
|
+
let entry;
|
|
436
|
+
fs.readdirSync(srcDir, { withFileTypes: true }).forEach(file => {
|
|
437
|
+
const pathname = path.join(srcDir, file.name);
|
|
457
438
|
try {
|
|
458
439
|
if (file.isDirectory()) {
|
|
459
440
|
if (recursive) {
|
|
@@ -465,16 +446,16 @@ function tryRemoveDir(value, empty, recursive) {
|
|
|
465
446
|
}
|
|
466
447
|
}
|
|
467
448
|
}
|
|
468
|
-
else if (!temp ||
|
|
449
|
+
else if (!temp || (entry = fs.statSync(pathname)) && entry.ctimeMs + empty <= current) {
|
|
469
450
|
fs.unlinkSync(pathname);
|
|
470
451
|
}
|
|
471
452
|
}
|
|
472
453
|
catch {
|
|
473
454
|
failed.push(pathname);
|
|
474
455
|
}
|
|
475
|
-
}
|
|
456
|
+
});
|
|
476
457
|
if (!empty && failed.length === 0) {
|
|
477
|
-
fs.rmdirSync(
|
|
458
|
+
fs.rmdirSync(srcDir);
|
|
478
459
|
}
|
|
479
460
|
return failed;
|
|
480
461
|
}
|
|
@@ -959,7 +940,7 @@ class Module extends EventEmitter {
|
|
|
959
940
|
this[_g] = null;
|
|
960
941
|
}
|
|
961
942
|
static get VERSION() {
|
|
962
|
-
return "0.10.
|
|
943
|
+
return "0.10.15";
|
|
963
944
|
}
|
|
964
945
|
static get LOG_TYPE() {
|
|
965
946
|
return types_1.LOG_TYPE;
|
|
@@ -1227,8 +1208,8 @@ class Module extends EventEmitter {
|
|
|
1227
1208
|
i = sessionIdColor || sessionIdBgColor || sessionIdBold ? formatLogColumn(i, sessionIdColor, sessionIdBgColor, sessionIdBold) : chalk.grey(i);
|
|
1228
1209
|
}
|
|
1229
1210
|
if ((m || unit) && SETTINGS.message !== false) {
|
|
1211
|
+
const formatMessage = format.message;
|
|
1230
1212
|
if (!error) {
|
|
1231
|
-
const formatMessage = format.message;
|
|
1232
1213
|
if (!messageColor && !messageBgColor) {
|
|
1233
1214
|
({ color: messageColor, bgColor: messageBgColor, bold: messageBold } = formatMessage);
|
|
1234
1215
|
messageBold ??= formatMessage.bold;
|
|
@@ -1278,6 +1259,7 @@ class Module extends EventEmitter {
|
|
|
1278
1259
|
catch {
|
|
1279
1260
|
m = chalk.redBright(L) + chalk.bgWhite.blackBright(m) + (R && chalk.redBright(R));
|
|
1280
1261
|
}
|
|
1262
|
+
m = chalk.blackBright(formatMessage.braces[0]) + m;
|
|
1281
1263
|
}
|
|
1282
1264
|
}
|
|
1283
1265
|
else {
|
|
@@ -1564,8 +1546,7 @@ class Module extends EventEmitter {
|
|
|
1564
1546
|
}
|
|
1565
1547
|
static isFile(value, type) {
|
|
1566
1548
|
if (!type) {
|
|
1567
|
-
value = asFile(value);
|
|
1568
|
-
return !!value && this.isPath(value, true);
|
|
1549
|
+
return this.isPath(value = asFile(value), true);
|
|
1569
1550
|
}
|
|
1570
1551
|
if (typeof value === 'string') {
|
|
1571
1552
|
switch (type) {
|
|
@@ -1783,11 +1764,11 @@ class Module extends EventEmitter {
|
|
|
1783
1764
|
}
|
|
1784
1765
|
static async copyDir(src, dest, move, recursive = true) {
|
|
1785
1766
|
const srcOut = sanitizePath(asFile(src));
|
|
1786
|
-
if (!
|
|
1767
|
+
if (!this.isDir(srcOut)) {
|
|
1787
1768
|
return Promise.reject(errorDirectory(asFile(src) || "Unknown"));
|
|
1788
1769
|
}
|
|
1789
1770
|
const destOut = sanitizePath(asFile(dest));
|
|
1790
|
-
if (!
|
|
1771
|
+
if (!this.createDir(destOut)) {
|
|
1791
1772
|
return Promise.reject(errorDirectory(asFile(dest) || "Unknown"));
|
|
1792
1773
|
}
|
|
1793
1774
|
let symFile, symDir, ignoreFile, ignoreDir, silent, overwrite;
|
|
@@ -1923,7 +1904,7 @@ class Module extends EventEmitter {
|
|
|
1923
1904
|
}
|
|
1924
1905
|
static async globDir(src, pattern, options) {
|
|
1925
1906
|
const outDir = sanitizePath(asFile(src));
|
|
1926
|
-
if (!
|
|
1907
|
+
if (!this.isDir(outDir)) {
|
|
1927
1908
|
return Promise.reject(errorDirectory(asFile(src) || "Unknown"));
|
|
1928
1909
|
}
|
|
1929
1910
|
const pmOpts = PLATFORM_WIN32 ? { nocase: true, windows: true, posixSlashes: true } : {};
|
|
@@ -1997,7 +1978,7 @@ class Module extends EventEmitter {
|
|
|
1997
1978
|
({ minStreamSize = 0, encoding, signal, cache } = options);
|
|
1998
1979
|
}
|
|
1999
1980
|
const src = sanitizePath(asFile(value));
|
|
2000
|
-
if (
|
|
1981
|
+
if (this.isPath(src, true)) {
|
|
2001
1982
|
return new Promise(async (resolve) => {
|
|
2002
1983
|
const fileSize = fs.statSync(src).size;
|
|
2003
1984
|
let data;
|
|
@@ -2034,7 +2015,7 @@ class Module extends EventEmitter {
|
|
|
2034
2015
|
({ minStreamSize, encoding, cache } = options);
|
|
2035
2016
|
}
|
|
2036
2017
|
const src = sanitizePath(asFile(value));
|
|
2037
|
-
if (
|
|
2018
|
+
if (this.isPath(src, true)) {
|
|
2038
2019
|
let result;
|
|
2039
2020
|
if (cache && (result = getCacheItem(CACHE_READTEXT, src))) {
|
|
2040
2021
|
return (minStreamSize !== undefined ? Promise.resolve(result) : result);
|
|
@@ -2063,7 +2044,7 @@ class Module extends EventEmitter {
|
|
|
2063
2044
|
({ minStreamSize, cache } = options);
|
|
2064
2045
|
}
|
|
2065
2046
|
const src = sanitizePath(asFile(value));
|
|
2066
|
-
if (
|
|
2047
|
+
if (this.isPath(src, true)) {
|
|
2067
2048
|
let result;
|
|
2068
2049
|
if (cache && (result = getCacheItem(CACHE_READBUFFER, src))) {
|
|
2069
2050
|
return (minStreamSize !== undefined ? Promise.resolve(result) : result);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-mc/module",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.15",
|
|
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.10.
|
|
23
|
+
"@e-mc/types": "0.10.15",
|
|
24
24
|
"chalk": "4.1.2",
|
|
25
25
|
"file-type": "^18.7.0",
|
|
26
26
|
"js-yaml": "^4.1.0",
|