@e-mc/module 0.9.11 → 0.9.12
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 +9 -7
- package/index.js +46 -5
- 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.9.
|
|
12
|
+
* [View Source](https://www.unpkg.com/@e-mc/types@0.9.12/lib/index.d.ts)
|
|
13
13
|
|
|
14
14
|
```typescript
|
|
15
15
|
import type { LogStatus } from "./squared";
|
|
@@ -17,7 +17,7 @@ import type { LogStatus } from "./squared";
|
|
|
17
17
|
import type { IHost } from "./index";
|
|
18
18
|
import type { IAbortComponent, IPermission } from "./core";
|
|
19
19
|
import type { LOG_TYPE, STATUS_TYPE, ExecCommand, LogArguments, LogComponent, LogDate, LogFailOptions, LogMessageOptions, LogOptions, LogProcessOptions, LogTime, LogType, LogValue, LoggerFormat, StatusType } from "./logger";
|
|
20
|
-
import type { AsHashOptions, CheckSemVerOptions, CopyDirOptions, CopyDirResult, CopyFileOptions, CreateDirOptions, DeleteFileOptions, GetTempDirOptions, MoveFileOptions, NormalizeFlags, ParseFunctionOptions, PermissionOptions, ProtocolType, ReadBufferOptions, ReadFileCallback, ReadFileOptions, ReadHashOptions, ReadTextOptions, RemoveDirOptions, WriteFileOptions } from "./module";
|
|
20
|
+
import type { AsHashOptions, CheckSemVerOptions, CopyDirOptions, CopyDirResult, CopyFileOptions, CreateDirOptions, DeleteFileOptions, GetTempDirOptions, GlobDirOptions, MoveFileOptions, NormalizeFlags, ParseFunctionOptions, PermissionOptions, ProtocolType, ReadBufferOptions, ReadFileCallback, ReadFileOptions, ReadHashOptions, ReadTextOptions, RemoveDirOptions, WriteFileOptions } from "./module";
|
|
21
21
|
import type { Settings } from "./node";
|
|
22
22
|
import type { LoggerFormatSettings } from "/settings";
|
|
23
23
|
|
|
@@ -200,6 +200,8 @@ interface ModuleConstructor {
|
|
|
200
200
|
removeDir(value: string | URL, empty?: boolean, recursive?: boolean): boolean;
|
|
201
201
|
copyDir(src: string | URL, dest: string | URL, move?: boolean, recursive?: boolean): Promise<CopyDirResult>;
|
|
202
202
|
copyDir(src: string | URL, dest: string | URL, options?: CopyDirOptions): Promise<CopyDirResult>;
|
|
203
|
+
globDir(src: string | URL, pattern: string | string[], recursive: boolean | number): Promise<string[]>;
|
|
204
|
+
globDir(src: string | URL, pattern: string | string[], options?: GlobDirOptions): Promise<string[]>;
|
|
203
205
|
renameFile(src: string | URL, dest: string | URL, throws?: boolean): boolean;
|
|
204
206
|
streamFile(src: string, cache: boolean): Promise<Buffer | string>;
|
|
205
207
|
streamFile(src: string, options: ReadBufferOptions): Promise<Buffer | string>;
|
|
@@ -392,11 +394,11 @@ type ForegroundColor = typeof IForegroundColor | `#${string}`;
|
|
|
392
394
|
|
|
393
395
|
## References
|
|
394
396
|
|
|
395
|
-
- https://www.unpkg.com/@e-mc/types@0.9.
|
|
396
|
-
- https://www.unpkg.com/@e-mc/types@0.9.
|
|
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.
|
|
397
|
+
- https://www.unpkg.com/@e-mc/types@0.9.12/lib/core.d.ts
|
|
398
|
+
- https://www.unpkg.com/@e-mc/types@0.9.12/lib/logger.d.ts
|
|
399
|
+
- https://www.unpkg.com/@e-mc/types@0.9.12/lib/module.d.ts
|
|
400
|
+
- https://www.unpkg.com/@e-mc/types@0.9.12/lib/node.d.ts
|
|
401
|
+
- https://www.unpkg.com/@e-mc/types@0.9.12/lib/settings.d.ts
|
|
400
402
|
|
|
401
403
|
* https://www.npmjs.com/package/@types/node
|
|
402
404
|
|
package/index.js
CHANGED
|
@@ -172,12 +172,12 @@ function setPnpmVer() {
|
|
|
172
172
|
return false;
|
|
173
173
|
}
|
|
174
174
|
const addPackage = (value) => {
|
|
175
|
-
let index = value.indexOf('(');
|
|
175
|
+
let index = (value = value.replace(/^\//, '')).indexOf('(');
|
|
176
176
|
if (index !== -1) {
|
|
177
177
|
value = value.substring(0, index);
|
|
178
178
|
}
|
|
179
|
-
index = value.lastIndexOf(value.indexOf('@',
|
|
180
|
-
const name = value.substring(0, index)
|
|
179
|
+
index = value.lastIndexOf(value.indexOf('@', 1) !== -1 ? '@' : '/');
|
|
180
|
+
const name = value.substring(0, index);
|
|
181
181
|
const version = value.substring(index + 1);
|
|
182
182
|
if (!items.find(item => item[0] === name && item[1] === version)) {
|
|
183
183
|
items.push([name, version]);
|
|
@@ -549,6 +549,20 @@ function addCacheItem(map, key, data, cache) {
|
|
|
549
549
|
map.set(key, [Date.now(), data]);
|
|
550
550
|
}
|
|
551
551
|
}
|
|
552
|
+
function listDir(src, paths, depth, include, exclude, outFiles) {
|
|
553
|
+
const srcDir = path.join(src, ...paths);
|
|
554
|
+
fs.readdirSync(srcDir, { withFileTypes: true }).forEach(file => {
|
|
555
|
+
if (file.isFile()) {
|
|
556
|
+
const pathname = path.join(srcDir, file.name);
|
|
557
|
+
if (include(pathname) && !exclude?.(pathname)) {
|
|
558
|
+
outFiles.push(pathname);
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
else if (depth > 0 && file.isDirectory()) {
|
|
562
|
+
listDir(src, paths.concat(file.name), depth - 1, include, exclude, outFiles);
|
|
563
|
+
}
|
|
564
|
+
});
|
|
565
|
+
}
|
|
552
566
|
function checkFunction(value) {
|
|
553
567
|
if (typeof value === 'function') {
|
|
554
568
|
Object.defineProperty(value, "__cjs__", { value: true, writable: false, enumerable: false });
|
|
@@ -721,7 +735,7 @@ class Module extends EventEmitter {
|
|
|
721
735
|
this[_f] = new AbortController();
|
|
722
736
|
this[_g] = null;
|
|
723
737
|
}
|
|
724
|
-
static get VERSION() { return "0.9.
|
|
738
|
+
static get VERSION() { return "0.9.12"; }
|
|
725
739
|
static get LOG_TYPE() { return types_1.LOG_TYPE; }
|
|
726
740
|
static get STATUS_TYPE() { return types_1.STATUS_TYPE; }
|
|
727
741
|
static get MAX_TIMEOUT() { return 2147483647; }
|
|
@@ -1687,6 +1701,33 @@ class Module extends EventEmitter {
|
|
|
1687
1701
|
});
|
|
1688
1702
|
});
|
|
1689
1703
|
}
|
|
1704
|
+
static async globDir(src, pattern, options) {
|
|
1705
|
+
const outDir = sanitizePath(asFile(src));
|
|
1706
|
+
if (!(outDir && this.isDir(outDir))) {
|
|
1707
|
+
return Promise.reject(errorDirectory(asFile(src) || "Unknown"));
|
|
1708
|
+
}
|
|
1709
|
+
const pmOpts = { posixSlashes: true, windows: true, nocase: PLATFORM_WIN32 };
|
|
1710
|
+
let exclude, recursive;
|
|
1711
|
+
if ((0, types_1.isObject)(options)) {
|
|
1712
|
+
if (options.matchBase) {
|
|
1713
|
+
pmOpts.matchBase = true;
|
|
1714
|
+
}
|
|
1715
|
+
if (options.contains) {
|
|
1716
|
+
pmOpts.contains = true;
|
|
1717
|
+
}
|
|
1718
|
+
if (options.dot) {
|
|
1719
|
+
pmOpts.dot = true;
|
|
1720
|
+
}
|
|
1721
|
+
({ exclude, recursive } = options);
|
|
1722
|
+
}
|
|
1723
|
+
else {
|
|
1724
|
+
recursive = options;
|
|
1725
|
+
}
|
|
1726
|
+
recursive ??= true;
|
|
1727
|
+
const result = [];
|
|
1728
|
+
listDir(outDir, [], !recursive ? 0 : typeof recursive === 'number' ? recursive : Infinity, pm(pattern, pmOpts), exclude ? pm(exclude, pmOpts) : undefined, result);
|
|
1729
|
+
return result;
|
|
1730
|
+
}
|
|
1690
1731
|
static renameFile(src, dest, throws = true) {
|
|
1691
1732
|
try {
|
|
1692
1733
|
fs.renameSync(src, dest);
|
|
@@ -2074,7 +2115,7 @@ class Module extends EventEmitter {
|
|
|
2074
2115
|
maxVersion = [Infinity];
|
|
2075
2116
|
}
|
|
2076
2117
|
else {
|
|
2077
|
-
maxVersion = [max - 1];
|
|
2118
|
+
maxVersion = [(max | 0) - 1];
|
|
2078
2119
|
maxRange = true;
|
|
2079
2120
|
}
|
|
2080
2121
|
let version = this.getPackageVersion(name, unstable, startDir);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-mc/module",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.12",
|
|
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": "BSD 3-Clause",
|
|
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.12",
|
|
24
24
|
"chalk": "4.1.2",
|
|
25
25
|
"file-type": "16.5.4",
|
|
26
26
|
"js-yaml": "^4.1.0",
|