@e-mc/module 0.9.22 → 0.9.24
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 +17 -37
- package/package.json +4 -4
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.9.
|
|
12
|
+
* [View Source](https://www.unpkg.com/@e-mc/types@0.9.24/lib/index.d.ts)
|
|
13
13
|
|
|
14
14
|
```typescript
|
|
15
15
|
import type { LogStatus } from "./squared";
|
|
@@ -394,11 +394,11 @@ type ForegroundColor = typeof IForegroundColor | `#${string}`;
|
|
|
394
394
|
|
|
395
395
|
## References
|
|
396
396
|
|
|
397
|
-
- https://www.unpkg.com/@e-mc/types@0.9.
|
|
398
|
-
- https://www.unpkg.com/@e-mc/types@0.9.
|
|
399
|
-
- https://www.unpkg.com/@e-mc/types@0.9.
|
|
400
|
-
- https://www.unpkg.com/@e-mc/types@0.9.
|
|
401
|
-
- https://www.unpkg.com/@e-mc/types@0.9.
|
|
397
|
+
- https://www.unpkg.com/@e-mc/types@0.9.24/lib/core.d.ts
|
|
398
|
+
- https://www.unpkg.com/@e-mc/types@0.9.24/lib/logger.d.ts
|
|
399
|
+
- https://www.unpkg.com/@e-mc/types@0.9.24/lib/module.d.ts
|
|
400
|
+
- https://www.unpkg.com/@e-mc/types@0.9.24/lib/node.d.ts
|
|
401
|
+
- https://www.unpkg.com/@e-mc/types@0.9.24/lib/settings.d.ts
|
|
402
402
|
|
|
403
403
|
* https://www.npmjs.com/package/@types/node
|
|
404
404
|
|
package/index.js
CHANGED
|
@@ -328,14 +328,14 @@ function tryCreateDir(value) {
|
|
|
328
328
|
}
|
|
329
329
|
return false;
|
|
330
330
|
}
|
|
331
|
-
function tryRemoveDir(
|
|
331
|
+
function tryRemoveDir(srcDir, empty, recursive) {
|
|
332
332
|
const temp = typeof empty === 'number';
|
|
333
333
|
let options;
|
|
334
334
|
if (!temp) {
|
|
335
335
|
try {
|
|
336
|
-
fs.rmSync(
|
|
336
|
+
fs.rmSync(srcDir, { recursive, force: true });
|
|
337
337
|
if (empty) {
|
|
338
|
-
fs.mkdirSync(
|
|
338
|
+
fs.mkdirSync(srcDir);
|
|
339
339
|
}
|
|
340
340
|
return [];
|
|
341
341
|
}
|
|
@@ -343,30 +343,11 @@ function tryRemoveDir(value, empty, recursive) {
|
|
|
343
343
|
}
|
|
344
344
|
options = { recursive };
|
|
345
345
|
}
|
|
346
|
-
value = Module.normalizePath(value, 1);
|
|
347
346
|
const failed = [];
|
|
348
|
-
const nameMap = new WeakMap();
|
|
349
|
-
let files;
|
|
350
|
-
if (temp) {
|
|
351
|
-
files = [];
|
|
352
|
-
fs.readdirSync(value).forEach(name => {
|
|
353
|
-
try {
|
|
354
|
-
const stat = fs.statSync(value + name);
|
|
355
|
-
nameMap.set(stat, name);
|
|
356
|
-
files.push(stat);
|
|
357
|
-
}
|
|
358
|
-
catch {
|
|
359
|
-
failed.push(value + name);
|
|
360
|
-
}
|
|
361
|
-
});
|
|
362
|
-
}
|
|
363
|
-
else {
|
|
364
|
-
files = fs.readdirSync(value, { withFileTypes: true });
|
|
365
|
-
}
|
|
366
347
|
const current = Date.now();
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
const pathname =
|
|
348
|
+
let entry;
|
|
349
|
+
fs.readdirSync(srcDir, { withFileTypes: true }).forEach(file => {
|
|
350
|
+
const pathname = path.join(srcDir, file.name);
|
|
370
351
|
try {
|
|
371
352
|
if (file.isDirectory()) {
|
|
372
353
|
if (recursive) {
|
|
@@ -378,16 +359,16 @@ function tryRemoveDir(value, empty, recursive) {
|
|
|
378
359
|
}
|
|
379
360
|
}
|
|
380
361
|
}
|
|
381
|
-
else if (!temp ||
|
|
362
|
+
else if (!temp || (entry = fs.statSync(pathname)) && entry.ctimeMs + empty <= current) {
|
|
382
363
|
fs.unlinkSync(pathname);
|
|
383
364
|
}
|
|
384
365
|
}
|
|
385
366
|
catch {
|
|
386
367
|
failed.push(pathname);
|
|
387
368
|
}
|
|
388
|
-
}
|
|
369
|
+
});
|
|
389
370
|
if (!empty && failed.length === 0) {
|
|
390
|
-
fs.rmdirSync(
|
|
371
|
+
fs.rmdirSync(srcDir);
|
|
391
372
|
}
|
|
392
373
|
return failed;
|
|
393
374
|
}
|
|
@@ -744,7 +725,7 @@ class Module extends EventEmitter {
|
|
|
744
725
|
this[_f] = new AbortController();
|
|
745
726
|
this[_g] = null;
|
|
746
727
|
}
|
|
747
|
-
static get VERSION() { return "0.9.
|
|
728
|
+
static get VERSION() { return "0.9.24"; }
|
|
748
729
|
static get LOG_TYPE() { return types_1.LOG_TYPE; }
|
|
749
730
|
static get STATUS_TYPE() { return types_1.STATUS_TYPE; }
|
|
750
731
|
static get MAX_TIMEOUT() { return 2147483647; }
|
|
@@ -1368,8 +1349,7 @@ class Module extends EventEmitter {
|
|
|
1368
1349
|
}
|
|
1369
1350
|
static isFile(value, type) {
|
|
1370
1351
|
if (!type) {
|
|
1371
|
-
value = asFile(value);
|
|
1372
|
-
return !!value && this.isPath(value, true);
|
|
1352
|
+
return this.isPath(value = asFile(value), true);
|
|
1373
1353
|
}
|
|
1374
1354
|
if (typeof value === 'string') {
|
|
1375
1355
|
switch (type) {
|
|
@@ -1586,11 +1566,11 @@ class Module extends EventEmitter {
|
|
|
1586
1566
|
}
|
|
1587
1567
|
static async copyDir(src, dest, move, recursive = true) {
|
|
1588
1568
|
const srcOut = sanitizePath(asFile(src));
|
|
1589
|
-
if (!
|
|
1569
|
+
if (!this.isDir(srcOut)) {
|
|
1590
1570
|
return Promise.reject(errorDirectory(asFile(src) || "Unknown"));
|
|
1591
1571
|
}
|
|
1592
1572
|
const destOut = sanitizePath(asFile(dest));
|
|
1593
|
-
if (!
|
|
1573
|
+
if (!this.createDir(destOut)) {
|
|
1594
1574
|
return Promise.reject(errorDirectory(asFile(dest) || "Unknown"));
|
|
1595
1575
|
}
|
|
1596
1576
|
let symFile, symDir, ignoreFile, ignoreDir, silent, overwrite;
|
|
@@ -1715,7 +1695,7 @@ class Module extends EventEmitter {
|
|
|
1715
1695
|
}
|
|
1716
1696
|
static async globDir(src, pattern, options) {
|
|
1717
1697
|
const outDir = sanitizePath(asFile(src));
|
|
1718
|
-
if (!
|
|
1698
|
+
if (!this.isDir(outDir)) {
|
|
1719
1699
|
return Promise.reject(errorDirectory(asFile(src) || "Unknown"));
|
|
1720
1700
|
}
|
|
1721
1701
|
const pmOpts = { posixSlashes: true, windows: true, nocase: PLATFORM_WIN32 };
|
|
@@ -1788,7 +1768,7 @@ class Module extends EventEmitter {
|
|
|
1788
1768
|
({ minStreamSize = 0, encoding, signal, cache } = options);
|
|
1789
1769
|
}
|
|
1790
1770
|
const src = sanitizePath(asFile(value));
|
|
1791
|
-
if (
|
|
1771
|
+
if (this.isPath(src, true)) {
|
|
1792
1772
|
return new Promise(async (resolve) => {
|
|
1793
1773
|
const fileSize = fs.statSync(src).size;
|
|
1794
1774
|
let data;
|
|
@@ -1825,7 +1805,7 @@ class Module extends EventEmitter {
|
|
|
1825
1805
|
({ minStreamSize, encoding, cache } = options);
|
|
1826
1806
|
}
|
|
1827
1807
|
const src = sanitizePath(asFile(value));
|
|
1828
|
-
if (
|
|
1808
|
+
if (this.isPath(src, true)) {
|
|
1829
1809
|
let result;
|
|
1830
1810
|
if (cache && (result = getCacheItem(CACHE_READTEXT, src))) {
|
|
1831
1811
|
return (minStreamSize !== undefined ? Promise.resolve(result) : result);
|
|
@@ -1854,7 +1834,7 @@ class Module extends EventEmitter {
|
|
|
1854
1834
|
({ minStreamSize, cache } = options);
|
|
1855
1835
|
}
|
|
1856
1836
|
const src = sanitizePath(asFile(value));
|
|
1857
|
-
if (
|
|
1837
|
+
if (this.isPath(src, true)) {
|
|
1858
1838
|
let result;
|
|
1859
1839
|
if (cache && (result = getCacheItem(CACHE_READBUFFER, src))) {
|
|
1860
1840
|
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.9.
|
|
3
|
+
"version": "0.9.24",
|
|
4
4
|
"description": "Module base class for E-mc.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -20,12 +20,12 @@
|
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"homepage": "https://github.com/anpham6/e-mc#readme",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@e-mc/types": "0.9.
|
|
23
|
+
"@e-mc/types": "0.9.24",
|
|
24
24
|
"chalk": "4.1.2",
|
|
25
25
|
"file-type": "16.5.4",
|
|
26
|
-
"js-yaml": "^4.1.
|
|
26
|
+
"js-yaml": "^4.1.1",
|
|
27
27
|
"mime-types": "^2.1.35",
|
|
28
|
-
"picomatch": "^4.0.
|
|
28
|
+
"picomatch": "^4.0.3",
|
|
29
29
|
"strip-ansi": "6.0.1"
|
|
30
30
|
}
|
|
31
31
|
}
|