@e-mc/module 0.8.13 → 0.8.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/LICENSE +6 -6
- package/README.md +241 -241
- package/index.d.ts +4 -4
- package/index.js +30 -29
- package/lib-v4.d.ts +4 -4
- package/package.json +33 -33
package/LICENSE
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
Copyright 2024 An Pham
|
|
2
|
-
|
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
-
|
|
5
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
-
|
|
1
|
+
Copyright 2024 An Pham
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
7
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,242 +1,242 @@
|
|
|
1
|
-
# @e-mc/module
|
|
2
|
-
|
|
3
|
-
* NodeJS 14
|
|
4
|
-
* ES2019
|
|
5
|
-
|
|
6
|
-
## General Usage
|
|
7
|
-
|
|
8
|
-
* [Read the Docs](https://e-mc.readthedocs.io)
|
|
9
|
-
|
|
10
|
-
## Interface
|
|
11
|
-
|
|
12
|
-
- https://www.unpkg.com/@e-mc/types@0.8.
|
|
13
|
-
|
|
14
|
-
```typescript
|
|
15
|
-
import type { LogStatus } from "./squared";
|
|
16
|
-
|
|
17
|
-
import type { IHost } from "./index";
|
|
18
|
-
import type { IAbortComponent, IPermission } from "./core";
|
|
19
|
-
import type { LOG_TYPE, STATUS_TYPE, ExecCommand, LogArguments, LogComponent, LogDate, LogFailOptions, LogMessageOptions, LogOptions, LogProcessOptions, LogTime, LogType, LogValue, 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";
|
|
21
|
-
import type { Settings } from "./node";
|
|
22
|
-
|
|
23
|
-
import type { SpawnOptions } from "child_process";
|
|
24
|
-
import type { BinaryLike } from "crypto";
|
|
25
|
-
import type { FileTypeResult } from "file-type";
|
|
26
|
-
import type { NoParamCallback } from "fs";
|
|
27
|
-
|
|
28
|
-
import type * as EventEmitter from "events";
|
|
29
|
-
|
|
30
|
-
type BufferView = Buffer | string | NodeJS.ArrayBufferView;
|
|
31
|
-
type CpuUsage = NodeJS.CpuUsage;
|
|
32
|
-
|
|
33
|
-
interface IModule extends EventEmitter, IAbortComponent {
|
|
34
|
-
readonly status: LogStatus<StatusType>[];
|
|
35
|
-
readonly errors: unknown[];
|
|
36
|
-
supported(major: number, minor?: number, patch?: number, lts?: boolean): boolean;
|
|
37
|
-
supports(name: string, value?: boolean): boolean;
|
|
38
|
-
getTempDir(options: GetTempDirOptions): string;
|
|
39
|
-
getTempDir(uuidDir: boolean, createDir?: boolean): string;
|
|
40
|
-
getTempDir(pathname: string, createDir?: boolean): string;
|
|
41
|
-
getTempDir(uuidDir: boolean, filename: string, createDir?: boolean): string;
|
|
42
|
-
getTempDir(pathname?: string, filename?: string, createDir?: boolean): string;
|
|
43
|
-
canRead(uri: string, options?: PermissionOptions): boolean;
|
|
44
|
-
canWrite(uri: string, options?: PermissionOptions): boolean;
|
|
45
|
-
readFile(src: string): Buffer | undefined;
|
|
46
|
-
readFile(src: string, options?: ReadFileOptions): Promise<Buffer | string> | Buffer | string | undefined;
|
|
47
|
-
readFile(src: string, promises: true): Promise<Buffer | undefined>;
|
|
48
|
-
readFile(src: string, options: ReadFileOptions, promises: true): Promise<Buffer | string | undefined>;
|
|
49
|
-
readFile(src: string, callback: ReadFileCallback<Buffer>): Buffer | undefined;
|
|
50
|
-
readFile(src: string, options: ReadFileOptions, callback: ReadFileCallback<Buffer | string>): Buffer | string | undefined;
|
|
51
|
-
writeFile(src: string, data: BufferView, options?: WriteFileOptions): boolean;
|
|
52
|
-
writeFile(src: string, data: BufferView, promises: true): Promise<boolean>;
|
|
53
|
-
writeFile(src: string, data: BufferView, options: WriteFileOptions, promises: true): Promise<boolean>;
|
|
54
|
-
writeFile(src: string, data: BufferView, callback: NoParamCallback): void;
|
|
55
|
-
writeFile(src: string, data: BufferView, options: WriteFileOptions, callback: NoParamCallback): void;
|
|
56
|
-
deleteFile(src: string, options?: DeleteFileOptions): boolean;
|
|
57
|
-
deleteFile(src: string, promises: true): Promise<boolean>;
|
|
58
|
-
deleteFile(src: string, options: DeleteFileOptions, promises: true): Promise<boolean>;
|
|
59
|
-
deleteFile(src: string, callback: NoParamCallback): void;
|
|
60
|
-
deleteFile(src: string, options: DeleteFileOptions, callback: NoParamCallback): void;
|
|
61
|
-
copyFile(src: string, dest: string, options?: CopyFileOptions): boolean;
|
|
62
|
-
copyFile(src: string, dest: string, promises: true): Promise<boolean>;
|
|
63
|
-
copyFile(src: string, dest: string, options: CopyFileOptions, promises: true): Promise<boolean>;
|
|
64
|
-
copyFile(src: string, dest: string, callback: NoParamCallback): void;
|
|
65
|
-
copyFile(src: string, dest: string, options: CopyFileOptions, callback: NoParamCallback): void;
|
|
66
|
-
moveFile(src: string, dest: string, options?: MoveFileOptions): boolean;
|
|
67
|
-
moveFile(src: string, dest: string, promises: true): Promise<boolean>;
|
|
68
|
-
moveFile(src: string, dest: string, options: MoveFileOptions, promises: true): Promise<boolean>;
|
|
69
|
-
moveFile(src: string, dest: string, callback: NoParamCallback): void;
|
|
70
|
-
moveFile(src: string, dest: string, options: MoveFileOptions, callback: NoParamCallback): void;
|
|
71
|
-
createDir(src: string, options?: CreateDirOptions): boolean;
|
|
72
|
-
createDir(src: string, promises: true): Promise<boolean>;
|
|
73
|
-
createDir(src: string, options: CreateDirOptions, promises: true): Promise<boolean>;
|
|
74
|
-
createDir(src: string, callback: NoParamCallback): void;
|
|
75
|
-
createDir(src: string, options: CreateDirOptions, callback: NoParamCallback): void;
|
|
76
|
-
removeDir(src: string, options?: RemoveDirOptions): boolean;
|
|
77
|
-
removeDir(src: string, promises: true): Promise<boolean>;
|
|
78
|
-
removeDir(src: string, options: RemoveDirOptions, promises: true): Promise<boolean>;
|
|
79
|
-
removeDir(src: string, callback: NoParamCallback): void;
|
|
80
|
-
removeDir(src: string, options: RemoveDirOptions, callback: NoParamCallback): void;
|
|
81
|
-
allSettled(values: readonly PromiseLike<unknown>[], rejected?: LogValue, options?: LogFailOptions | LogType): Promise<PromiseFulfilledResult<unknown>[]>;
|
|
82
|
-
formatMessage(type: LogType, title: string, value: LogValue, message?: unknown, options?: LogMessageOptions): void;
|
|
83
|
-
formatFail(type: LogType, title: string, value: LogValue, message?: unknown, options?: LogFailOptions): void;
|
|
84
|
-
writeFail(value: LogValue, message?: unknown, options?: LogFailOptions | LogType): void;
|
|
85
|
-
writeTimeProcess(title: string, value: string, startTime: LogTime, options?: LogProcessOptions): void;
|
|
86
|
-
writeTimeElapsed(title: string, value: LogValue, startTime: LogTime, options?: LogMessageOptions): void;
|
|
87
|
-
checkPackage(err: unknown, name: string | undefined, options?: LogFailOptions | LogType): boolean;
|
|
88
|
-
checkPackage(err: unknown, name: string | undefined, value?: LogValue, options?: LogFailOptions | LogType): boolean;
|
|
89
|
-
checkFail(message: unknown, options: LogFailOptions): LogArguments | false | undefined;
|
|
90
|
-
writeLog(component: LogComponent, queue?: boolean): void;
|
|
91
|
-
writeLog(type: StatusType, value: unknown, options?: LogOptions): void;
|
|
92
|
-
writeLog(type: StatusType, value: unknown, timeStamp?: LogDate, duration?: number): void;
|
|
93
|
-
addLog(component: LogComponent, queue?: boolean): void;
|
|
94
|
-
addLog(type: StatusType, value: unknown, from: string, source?: string): void;
|
|
95
|
-
addLog(type: StatusType, value: unknown, options?: LogOptions): void;
|
|
96
|
-
addLog(type: StatusType, value: unknown, timeStamp?: LogDate, from?: string, source?: string): void;
|
|
97
|
-
addLog(type: StatusType, value: unknown, timeStamp?: LogDate, duration?: number, from?: string, source?: string): void;
|
|
98
|
-
getLog(...type: StatusType[]): LogStatus<StatusType>[];
|
|
99
|
-
flushLog(): void;
|
|
100
|
-
willAbort(value: unknown): boolean;
|
|
101
|
-
hasOwnPermission(): boolean;
|
|
102
|
-
isFatal(err?: unknown): boolean;
|
|
103
|
-
detach(): void;
|
|
104
|
-
reset(): void;
|
|
105
|
-
get moduleName(): string;
|
|
106
|
-
set host(value);
|
|
107
|
-
get host(): IHost | null;
|
|
108
|
-
set permission(value);
|
|
109
|
-
get permission(): IPermission | null;
|
|
110
|
-
get aborted(): boolean;
|
|
111
|
-
set abortable(value);
|
|
112
|
-
get abortable(): boolean;
|
|
113
|
-
get threadable(): boolean;
|
|
114
|
-
set sessionId(value);
|
|
115
|
-
get sessionId(): string;
|
|
116
|
-
set broadcastId(value);
|
|
117
|
-
get broadcastId(): string | string[];
|
|
118
|
-
get logType(): LOG_TYPE;
|
|
119
|
-
set logLevel(value: number | string);
|
|
120
|
-
get logLevel(): number;
|
|
121
|
-
get statusType(): STATUS_TYPE;
|
|
122
|
-
set tempDir(value);
|
|
123
|
-
get tempDir(): string;
|
|
124
|
-
|
|
125
|
-
/* EventEmitter */
|
|
126
|
-
on(event: "exec", listener: (command: ExecCommand, options?: SpawnOptions) => void): this;
|
|
127
|
-
on(event: "error", listener: (err: Error) => void): this;
|
|
128
|
-
on(event: "file:read", listener: (src: string, data: Buffer | string, options?: ReadFileOptions) => void): this;
|
|
129
|
-
on(event: "file:write", listener: (src: string, options?: WriteFileOptions) => void): this;
|
|
130
|
-
on(event: "file:delete", listener: (src: string, options?: DeleteFileOptions) => void): this;
|
|
131
|
-
on(event: "file:copy", listener: (dest: string, options?: CopyFileOptions) => void): this;
|
|
132
|
-
on(event: "file:move", listener: (dest: string, options?: MoveFileOptions) => void): this;
|
|
133
|
-
on(event: "dir:create", listener: (src: string, options?: CreateDirOptions) => void): this;
|
|
134
|
-
on(event: "dir:remove", listener: (src: string, options?: RemoveDirOptions) => void): this;
|
|
135
|
-
once(event: "exec", listener: (command: ExecCommand, options?: SpawnOptions) => void): this;
|
|
136
|
-
once(event: "error", listener: (err: Error) => void): this;
|
|
137
|
-
once(event: "file:read", listener: (src: string, data: Buffer | string, options?: ReadFileOptions) => void): this;
|
|
138
|
-
once(event: "file:write", listener: (src: string, options?: WriteFileOptions) => void): this;
|
|
139
|
-
once(event: "file:delete", listener: (src: string, options?: DeleteFileOptions) => void): this;
|
|
140
|
-
once(event: "file:copy", listener: (dest: string, options?: CopyFileOptions) => void): this;
|
|
141
|
-
once(event: "file:move", listener: (dest: string, options?: MoveFileOptions) => void): this;
|
|
142
|
-
once(event: "dir:create", listener: (src: string, options?: CreateDirOptions) => void): this;
|
|
143
|
-
once(event: "dir:remove", listener: (src: string, options?: RemoveDirOptions) => void): this;
|
|
144
|
-
emit(event: "exec", command: ExecCommand, options?: SpawnOptions): boolean;
|
|
145
|
-
emit(event: "error", err: Error): boolean;
|
|
146
|
-
emit(event: "file:read", src: string, data: Buffer | string, options?: ReadFileOptions): boolean;
|
|
147
|
-
emit(event: "file:write", src: string, options?: WriteFileOptions): boolean;
|
|
148
|
-
emit(event: "file:delete", src: string, options?: DeleteFileOptions): boolean;
|
|
149
|
-
emit(event: "file:copy", dest: string, options?: CopyFileOptions): boolean;
|
|
150
|
-
emit(event: "file:move", dest: string, options?: MoveFileOptions): boolean;
|
|
151
|
-
emit(event: "dir:create", src: string, options?: CreateDirOptions): boolean;
|
|
152
|
-
emit(event: "dir:remove", src: string, options?: RemoveDirOptions): boolean;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
interface ModuleConstructor {
|
|
156
|
-
PROCESS_TIMEOUT: number;
|
|
157
|
-
LOG_STYLE_FAIL: LogMessageOptions;
|
|
158
|
-
LOG_STYLE_SUCCESS: LogMessageOptions;
|
|
159
|
-
LOG_STYLE_INFO: LogMessageOptions;
|
|
160
|
-
LOG_STYLE_WARN: LogMessageOptions;
|
|
161
|
-
LOG_STYLE_NOTICE: LogMessageOptions;
|
|
162
|
-
LOG_STYLE_REVERSE: LogMessageOptions;
|
|
163
|
-
readonly VERSION: string;
|
|
164
|
-
readonly LOG_TYPE: LOG_TYPE;
|
|
165
|
-
readonly STATUS_TYPE: STATUS_TYPE;
|
|
166
|
-
readonly MAX_TIMEOUT: number;
|
|
167
|
-
readonly TEMP_DIR: string;
|
|
168
|
-
supported(major: number, minor?: number, patch?: number, lts?: boolean): boolean;
|
|
169
|
-
formatMessage(type: LogType, title: string, value: LogValue, message?: unknown, options?: LogMessageOptions): void;
|
|
170
|
-
writeFail(value: LogValue, message?: unknown, options?: LogFailOptions | LogType): void;
|
|
171
|
-
enabled(key: string, username?: string): boolean;
|
|
172
|
-
parseFunction(value: unknown, options?: ParseFunctionOptions): ((...args: unknown[]) => Promise<unknown> | unknown) | null;
|
|
173
|
-
parseFunction(value: unknown, absolute: boolean, sync?: boolean): ((...args: unknown[]) => Promise<unknown> | unknown) | null;
|
|
174
|
-
asString(value: unknown, cacheKey?: boolean | "throws"): string;
|
|
175
|
-
asHash(data: BinaryLike, options: AsHashOptions): string;
|
|
176
|
-
asHash(data: BinaryLike,
|
|
177
|
-
asHash(data: BinaryLike, algorithm?:
|
|
178
|
-
readHash(value: string | URL, options?: ReadHashOptions): Promise<string>;
|
|
179
|
-
toPosix(value: unknown, normalize: boolean): string;
|
|
180
|
-
toPosix(value: unknown, filename?: string, normalize?: boolean): string;
|
|
181
|
-
hasLogType(value: LogType): boolean;
|
|
182
|
-
isURL(value: string, ...exclude: string[]): boolean;
|
|
183
|
-
isFile(value: string | URL, type?: ProtocolType): boolean;
|
|
184
|
-
isDir(value: string | URL): boolean;
|
|
185
|
-
isPath(value: string | URL, type?: "unc" | "unc-exists"): boolean;
|
|
186
|
-
isPath(value: string | URL, isFile?: boolean): boolean;
|
|
187
|
-
isErrorCode(err: unknown, ...code: string[]): boolean;
|
|
188
|
-
fromLocalPath(value: string): string;
|
|
189
|
-
resolveFile(value: string): string;
|
|
190
|
-
resolvePath(value: string, base: string | URL): string;
|
|
191
|
-
joinPath(...values: [...paths: unknown[], normalize: boolean][]): string;
|
|
192
|
-
joinPath(...values: unknown[]): string;
|
|
193
|
-
normalizePath(value: unknown, flags?: boolean | NormalizeFlags): string;
|
|
194
|
-
createDir(value: string | URL, overwrite?: boolean): boolean;
|
|
195
|
-
removeDir(value: string | URL, sinceCreated: number, recursive?: boolean): boolean;
|
|
196
|
-
removeDir(value: string | URL, empty?: boolean, recursive?: boolean): boolean;
|
|
197
|
-
copyDir(src: string | URL, dest: string | URL, options: CopyDirOptions): Promise<CopyDirResult>;
|
|
198
|
-
copyDir(src: string | URL, dest: string | URL, move?: boolean, recursive?: boolean): Promise<CopyDirResult>;
|
|
199
|
-
renameFile(src: string | URL, dest: string | URL, throws?: boolean): boolean;
|
|
200
|
-
streamFile(src: string, cache: boolean): Promise<Buffer | string>;
|
|
201
|
-
streamFile(src: string, options: ReadBufferOptions): Promise<Buffer | string>;
|
|
202
|
-
streamFile(src: string, cache?: boolean | ReadBufferOptions, options?: ReadBufferOptions): Promise<Buffer | string>;
|
|
203
|
-
readText(value: string | URL, cache: boolean): string;
|
|
204
|
-
readText(value: string | URL, options: ReadTextOptions): Promise<string> | string;
|
|
205
|
-
readText(value: string | URL, encoding?: BufferEncoding | boolean | ReadTextOptions, cache?: boolean): string;
|
|
206
|
-
readBuffer(value: string | URL, options: ReadBufferOptions): Promise<Buffer | null> | Buffer | null;
|
|
207
|
-
readBuffer(value: string | URL, cache?: boolean): Buffer | null;
|
|
208
|
-
resolveMime(data: string | Buffer | Uint8Array | ArrayBuffer): Promise<FileTypeResult | undefined>;
|
|
209
|
-
lookupMime(value: string, extension?: boolean): string;
|
|
210
|
-
initCpuUsage(instance?: IModule): CpuUsage;
|
|
211
|
-
getCpuUsage(start: CpuUsage, format: true): string;
|
|
212
|
-
getCpuUsage(start: CpuUsage, format?: boolean): number;
|
|
213
|
-
getMemUsage(format: true): string;
|
|
214
|
-
getMemUsage(format?: boolean): number;
|
|
215
|
-
formatCpuMem(start: CpuUsage, all?: boolean): string;
|
|
216
|
-
getPackageVersion(name: string | [string, string], startDir: string, baseDir?: string): string;
|
|
217
|
-
getPackageVersion(name: string | [string, string], unstable?: boolean, startDir?: string, baseDir?: string): string;
|
|
218
|
-
checkSemVer(name: string | [string, string], options: CheckSemVerOptions): boolean;
|
|
219
|
-
checkSemVer(name: string | [string, string], min: number | string, max: number | string, options: CheckSemVerOptions): boolean;
|
|
220
|
-
checkSemVer(name: string | [string, string], min: number | string, max?: number | string, unstable?: boolean, startDir?: string): boolean;
|
|
221
|
-
sanitizeCmd(value: string): string;
|
|
222
|
-
sanitizeArgs(value: string, doubleQuote?: boolean): string;
|
|
223
|
-
sanitizeArgs(values: string[], doubleQuote?: boolean): string[];
|
|
224
|
-
purgeMemory(percent: number, parent: boolean | number): Promise<number>;
|
|
225
|
-
purgeMemory(percent?: number, limit?: number, parent?: boolean | number): Promise<number>;
|
|
226
|
-
canWrite(name: "temp" | "home"): boolean;
|
|
227
|
-
loadSettings(settings: Settings, password?: string): boolean;
|
|
228
|
-
readonly prototype: IModule<IHost>;
|
|
229
|
-
new(): IModule<IHost>;
|
|
230
|
-
}
|
|
231
|
-
```
|
|
232
|
-
|
|
233
|
-
## References
|
|
234
|
-
|
|
235
|
-
- https://www.unpkg.com/@e-mc/types@0.8.
|
|
236
|
-
- https://www.unpkg.com/@e-mc/types@0.8.
|
|
237
|
-
- https://www.unpkg.com/@e-mc/types@0.8.
|
|
238
|
-
- https://www.unpkg.com/@e-mc/types@0.8.
|
|
239
|
-
|
|
240
|
-
## LICENSE
|
|
241
|
-
|
|
1
|
+
# @e-mc/module
|
|
2
|
+
|
|
3
|
+
* NodeJS 14
|
|
4
|
+
* ES2019
|
|
5
|
+
|
|
6
|
+
## General Usage
|
|
7
|
+
|
|
8
|
+
* [Read the Docs](https://e-mc.readthedocs.io)
|
|
9
|
+
|
|
10
|
+
## Interface
|
|
11
|
+
|
|
12
|
+
- https://www.unpkg.com/@e-mc/types@0.8.15/lib/index.d.ts
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
import type { LogStatus } from "./squared";
|
|
16
|
+
|
|
17
|
+
import type { IHost } from "./index";
|
|
18
|
+
import type { IAbortComponent, IPermission } from "./core";
|
|
19
|
+
import type { LOG_TYPE, STATUS_TYPE, ExecCommand, LogArguments, LogComponent, LogDate, LogFailOptions, LogMessageOptions, LogOptions, LogProcessOptions, LogTime, LogType, LogValue, 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";
|
|
21
|
+
import type { Settings } from "./node";
|
|
22
|
+
|
|
23
|
+
import type { SpawnOptions } from "child_process";
|
|
24
|
+
import type { BinaryLike } from "crypto";
|
|
25
|
+
import type { FileTypeResult } from "file-type";
|
|
26
|
+
import type { NoParamCallback } from "fs";
|
|
27
|
+
|
|
28
|
+
import type * as EventEmitter from "events";
|
|
29
|
+
|
|
30
|
+
type BufferView = Buffer | string | NodeJS.ArrayBufferView;
|
|
31
|
+
type CpuUsage = NodeJS.CpuUsage;
|
|
32
|
+
|
|
33
|
+
interface IModule extends EventEmitter, IAbortComponent {
|
|
34
|
+
readonly status: LogStatus<StatusType>[];
|
|
35
|
+
readonly errors: unknown[];
|
|
36
|
+
supported(major: number, minor?: number, patch?: number, lts?: boolean): boolean;
|
|
37
|
+
supports(name: string, value?: boolean): boolean;
|
|
38
|
+
getTempDir(options: GetTempDirOptions): string;
|
|
39
|
+
getTempDir(uuidDir: boolean, createDir?: boolean): string;
|
|
40
|
+
getTempDir(pathname: string, createDir?: boolean): string;
|
|
41
|
+
getTempDir(uuidDir: boolean, filename: string, createDir?: boolean): string;
|
|
42
|
+
getTempDir(pathname?: string, filename?: string, createDir?: boolean): string;
|
|
43
|
+
canRead(uri: string, options?: PermissionOptions): boolean;
|
|
44
|
+
canWrite(uri: string, options?: PermissionOptions): boolean;
|
|
45
|
+
readFile(src: string): Buffer | undefined;
|
|
46
|
+
readFile(src: string, options?: ReadFileOptions): Promise<Buffer | string> | Buffer | string | undefined;
|
|
47
|
+
readFile(src: string, promises: true): Promise<Buffer | undefined>;
|
|
48
|
+
readFile(src: string, options: ReadFileOptions, promises: true): Promise<Buffer | string | undefined>;
|
|
49
|
+
readFile(src: string, callback: ReadFileCallback<Buffer>): Buffer | undefined;
|
|
50
|
+
readFile(src: string, options: ReadFileOptions, callback: ReadFileCallback<Buffer | string>): Buffer | string | undefined;
|
|
51
|
+
writeFile(src: string, data: BufferView, options?: WriteFileOptions): boolean;
|
|
52
|
+
writeFile(src: string, data: BufferView, promises: true): Promise<boolean>;
|
|
53
|
+
writeFile(src: string, data: BufferView, options: WriteFileOptions, promises: true): Promise<boolean>;
|
|
54
|
+
writeFile(src: string, data: BufferView, callback: NoParamCallback): void;
|
|
55
|
+
writeFile(src: string, data: BufferView, options: WriteFileOptions, callback: NoParamCallback): void;
|
|
56
|
+
deleteFile(src: string, options?: DeleteFileOptions): boolean;
|
|
57
|
+
deleteFile(src: string, promises: true): Promise<boolean>;
|
|
58
|
+
deleteFile(src: string, options: DeleteFileOptions, promises: true): Promise<boolean>;
|
|
59
|
+
deleteFile(src: string, callback: NoParamCallback): void;
|
|
60
|
+
deleteFile(src: string, options: DeleteFileOptions, callback: NoParamCallback): void;
|
|
61
|
+
copyFile(src: string, dest: string, options?: CopyFileOptions): boolean;
|
|
62
|
+
copyFile(src: string, dest: string, promises: true): Promise<boolean>;
|
|
63
|
+
copyFile(src: string, dest: string, options: CopyFileOptions, promises: true): Promise<boolean>;
|
|
64
|
+
copyFile(src: string, dest: string, callback: NoParamCallback): void;
|
|
65
|
+
copyFile(src: string, dest: string, options: CopyFileOptions, callback: NoParamCallback): void;
|
|
66
|
+
moveFile(src: string, dest: string, options?: MoveFileOptions): boolean;
|
|
67
|
+
moveFile(src: string, dest: string, promises: true): Promise<boolean>;
|
|
68
|
+
moveFile(src: string, dest: string, options: MoveFileOptions, promises: true): Promise<boolean>;
|
|
69
|
+
moveFile(src: string, dest: string, callback: NoParamCallback): void;
|
|
70
|
+
moveFile(src: string, dest: string, options: MoveFileOptions, callback: NoParamCallback): void;
|
|
71
|
+
createDir(src: string, options?: CreateDirOptions): boolean;
|
|
72
|
+
createDir(src: string, promises: true): Promise<boolean>;
|
|
73
|
+
createDir(src: string, options: CreateDirOptions, promises: true): Promise<boolean>;
|
|
74
|
+
createDir(src: string, callback: NoParamCallback): void;
|
|
75
|
+
createDir(src: string, options: CreateDirOptions, callback: NoParamCallback): void;
|
|
76
|
+
removeDir(src: string, options?: RemoveDirOptions): boolean;
|
|
77
|
+
removeDir(src: string, promises: true): Promise<boolean>;
|
|
78
|
+
removeDir(src: string, options: RemoveDirOptions, promises: true): Promise<boolean>;
|
|
79
|
+
removeDir(src: string, callback: NoParamCallback): void;
|
|
80
|
+
removeDir(src: string, options: RemoveDirOptions, callback: NoParamCallback): void;
|
|
81
|
+
allSettled(values: readonly PromiseLike<unknown>[], rejected?: LogValue, options?: LogFailOptions | LogType): Promise<PromiseFulfilledResult<unknown>[]>;
|
|
82
|
+
formatMessage(type: LogType, title: string, value: LogValue, message?: unknown, options?: LogMessageOptions): void;
|
|
83
|
+
formatFail(type: LogType, title: string, value: LogValue, message?: unknown, options?: LogFailOptions): void;
|
|
84
|
+
writeFail(value: LogValue, message?: unknown, options?: LogFailOptions | LogType): void;
|
|
85
|
+
writeTimeProcess(title: string, value: string, startTime: LogTime, options?: LogProcessOptions): void;
|
|
86
|
+
writeTimeElapsed(title: string, value: LogValue, startTime: LogTime, options?: LogMessageOptions): void;
|
|
87
|
+
checkPackage(err: unknown, name: string | undefined, options?: LogFailOptions | LogType): boolean;
|
|
88
|
+
checkPackage(err: unknown, name: string | undefined, value?: LogValue, options?: LogFailOptions | LogType): boolean;
|
|
89
|
+
checkFail(message: unknown, options: LogFailOptions): LogArguments | false | undefined;
|
|
90
|
+
writeLog(component: LogComponent, queue?: boolean): void;
|
|
91
|
+
writeLog(type: StatusType, value: unknown, options?: LogOptions): void;
|
|
92
|
+
writeLog(type: StatusType, value: unknown, timeStamp?: LogDate, duration?: number): void;
|
|
93
|
+
addLog(component: LogComponent, queue?: boolean): void;
|
|
94
|
+
addLog(type: StatusType, value: unknown, from: string, source?: string): void;
|
|
95
|
+
addLog(type: StatusType, value: unknown, options?: LogOptions): void;
|
|
96
|
+
addLog(type: StatusType, value: unknown, timeStamp?: LogDate, from?: string, source?: string): void;
|
|
97
|
+
addLog(type: StatusType, value: unknown, timeStamp?: LogDate, duration?: number, from?: string, source?: string): void;
|
|
98
|
+
getLog(...type: StatusType[]): LogStatus<StatusType>[];
|
|
99
|
+
flushLog(): void;
|
|
100
|
+
willAbort(value: unknown): boolean;
|
|
101
|
+
hasOwnPermission(): boolean;
|
|
102
|
+
isFatal(err?: unknown): boolean;
|
|
103
|
+
detach(): void;
|
|
104
|
+
reset(): void;
|
|
105
|
+
get moduleName(): string;
|
|
106
|
+
set host(value);
|
|
107
|
+
get host(): IHost | null;
|
|
108
|
+
set permission(value);
|
|
109
|
+
get permission(): IPermission | null;
|
|
110
|
+
get aborted(): boolean;
|
|
111
|
+
set abortable(value);
|
|
112
|
+
get abortable(): boolean;
|
|
113
|
+
get threadable(): boolean;
|
|
114
|
+
set sessionId(value);
|
|
115
|
+
get sessionId(): string;
|
|
116
|
+
set broadcastId(value);
|
|
117
|
+
get broadcastId(): string | string[];
|
|
118
|
+
get logType(): LOG_TYPE;
|
|
119
|
+
set logLevel(value: number | string);
|
|
120
|
+
get logLevel(): number;
|
|
121
|
+
get statusType(): STATUS_TYPE;
|
|
122
|
+
set tempDir(value);
|
|
123
|
+
get tempDir(): string;
|
|
124
|
+
|
|
125
|
+
/* EventEmitter */
|
|
126
|
+
on(event: "exec", listener: (command: ExecCommand, options?: SpawnOptions) => void): this;
|
|
127
|
+
on(event: "error", listener: (err: Error) => void): this;
|
|
128
|
+
on(event: "file:read", listener: (src: string, data: Buffer | string, options?: ReadFileOptions) => void): this;
|
|
129
|
+
on(event: "file:write", listener: (src: string, options?: WriteFileOptions) => void): this;
|
|
130
|
+
on(event: "file:delete", listener: (src: string, options?: DeleteFileOptions) => void): this;
|
|
131
|
+
on(event: "file:copy", listener: (dest: string, options?: CopyFileOptions) => void): this;
|
|
132
|
+
on(event: "file:move", listener: (dest: string, options?: MoveFileOptions) => void): this;
|
|
133
|
+
on(event: "dir:create", listener: (src: string, options?: CreateDirOptions) => void): this;
|
|
134
|
+
on(event: "dir:remove", listener: (src: string, options?: RemoveDirOptions) => void): this;
|
|
135
|
+
once(event: "exec", listener: (command: ExecCommand, options?: SpawnOptions) => void): this;
|
|
136
|
+
once(event: "error", listener: (err: Error) => void): this;
|
|
137
|
+
once(event: "file:read", listener: (src: string, data: Buffer | string, options?: ReadFileOptions) => void): this;
|
|
138
|
+
once(event: "file:write", listener: (src: string, options?: WriteFileOptions) => void): this;
|
|
139
|
+
once(event: "file:delete", listener: (src: string, options?: DeleteFileOptions) => void): this;
|
|
140
|
+
once(event: "file:copy", listener: (dest: string, options?: CopyFileOptions) => void): this;
|
|
141
|
+
once(event: "file:move", listener: (dest: string, options?: MoveFileOptions) => void): this;
|
|
142
|
+
once(event: "dir:create", listener: (src: string, options?: CreateDirOptions) => void): this;
|
|
143
|
+
once(event: "dir:remove", listener: (src: string, options?: RemoveDirOptions) => void): this;
|
|
144
|
+
emit(event: "exec", command: ExecCommand, options?: SpawnOptions): boolean;
|
|
145
|
+
emit(event: "error", err: Error): boolean;
|
|
146
|
+
emit(event: "file:read", src: string, data: Buffer | string, options?: ReadFileOptions): boolean;
|
|
147
|
+
emit(event: "file:write", src: string, options?: WriteFileOptions): boolean;
|
|
148
|
+
emit(event: "file:delete", src: string, options?: DeleteFileOptions): boolean;
|
|
149
|
+
emit(event: "file:copy", dest: string, options?: CopyFileOptions): boolean;
|
|
150
|
+
emit(event: "file:move", dest: string, options?: MoveFileOptions): boolean;
|
|
151
|
+
emit(event: "dir:create", src: string, options?: CreateDirOptions): boolean;
|
|
152
|
+
emit(event: "dir:remove", src: string, options?: RemoveDirOptions): boolean;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
interface ModuleConstructor {
|
|
156
|
+
PROCESS_TIMEOUT: number;
|
|
157
|
+
LOG_STYLE_FAIL: LogMessageOptions;
|
|
158
|
+
LOG_STYLE_SUCCESS: LogMessageOptions;
|
|
159
|
+
LOG_STYLE_INFO: LogMessageOptions;
|
|
160
|
+
LOG_STYLE_WARN: LogMessageOptions;
|
|
161
|
+
LOG_STYLE_NOTICE: LogMessageOptions;
|
|
162
|
+
LOG_STYLE_REVERSE: LogMessageOptions;
|
|
163
|
+
readonly VERSION: string;
|
|
164
|
+
readonly LOG_TYPE: LOG_TYPE;
|
|
165
|
+
readonly STATUS_TYPE: STATUS_TYPE;
|
|
166
|
+
readonly MAX_TIMEOUT: number;
|
|
167
|
+
readonly TEMP_DIR: string;
|
|
168
|
+
supported(major: number, minor?: number, patch?: number, lts?: boolean): boolean;
|
|
169
|
+
formatMessage(type: LogType, title: string, value: LogValue, message?: unknown, options?: LogMessageOptions): void;
|
|
170
|
+
writeFail(value: LogValue, message?: unknown, options?: LogFailOptions | LogType): void;
|
|
171
|
+
enabled(key: string, username?: string): boolean;
|
|
172
|
+
parseFunction(value: unknown, options?: ParseFunctionOptions): ((...args: unknown[]) => Promise<unknown> | unknown) | null;
|
|
173
|
+
parseFunction(value: unknown, absolute: boolean, sync?: boolean): ((...args: unknown[]) => Promise<unknown> | unknown) | null;
|
|
174
|
+
asString(value: unknown, cacheKey?: boolean | "throws"): string;
|
|
175
|
+
asHash(data: BinaryLike, options: AsHashOptions): string;
|
|
176
|
+
asHash(data: BinaryLike, digest: unknown): string;
|
|
177
|
+
asHash(data: BinaryLike, algorithm?: NumString | AsHashOptions, digest?: unknown): string;
|
|
178
|
+
readHash(value: string | URL, options?: ReadHashOptions): Promise<string>;
|
|
179
|
+
toPosix(value: unknown, normalize: boolean): string;
|
|
180
|
+
toPosix(value: unknown, filename?: string, normalize?: boolean): string;
|
|
181
|
+
hasLogType(value: LogType): boolean;
|
|
182
|
+
isURL(value: string, ...exclude: string[]): boolean;
|
|
183
|
+
isFile(value: string | URL, type?: ProtocolType): boolean;
|
|
184
|
+
isDir(value: string | URL): boolean;
|
|
185
|
+
isPath(value: string | URL, type?: "unc" | "unc-exists"): boolean;
|
|
186
|
+
isPath(value: string | URL, isFile?: boolean): boolean;
|
|
187
|
+
isErrorCode(err: unknown, ...code: string[]): boolean;
|
|
188
|
+
fromLocalPath(value: string): string;
|
|
189
|
+
resolveFile(value: string): string;
|
|
190
|
+
resolvePath(value: string, base: string | URL): string;
|
|
191
|
+
joinPath(...values: [...paths: unknown[], normalize: boolean][]): string;
|
|
192
|
+
joinPath(...values: unknown[]): string;
|
|
193
|
+
normalizePath(value: unknown, flags?: boolean | NormalizeFlags): string;
|
|
194
|
+
createDir(value: string | URL, overwrite?: boolean): boolean;
|
|
195
|
+
removeDir(value: string | URL, sinceCreated: number, recursive?: boolean): boolean;
|
|
196
|
+
removeDir(value: string | URL, empty?: boolean, recursive?: boolean): boolean;
|
|
197
|
+
copyDir(src: string | URL, dest: string | URL, options: CopyDirOptions): Promise<CopyDirResult>;
|
|
198
|
+
copyDir(src: string | URL, dest: string | URL, move?: boolean, recursive?: boolean): Promise<CopyDirResult>;
|
|
199
|
+
renameFile(src: string | URL, dest: string | URL, throws?: boolean): boolean;
|
|
200
|
+
streamFile(src: string, cache: boolean): Promise<Buffer | string>;
|
|
201
|
+
streamFile(src: string, options: ReadBufferOptions): Promise<Buffer | string>;
|
|
202
|
+
streamFile(src: string, cache?: boolean | ReadBufferOptions, options?: ReadBufferOptions): Promise<Buffer | string>;
|
|
203
|
+
readText(value: string | URL, cache: boolean): string;
|
|
204
|
+
readText(value: string | URL, options: ReadTextOptions): Promise<string> | string;
|
|
205
|
+
readText(value: string | URL, encoding?: BufferEncoding | boolean | ReadTextOptions, cache?: boolean): string;
|
|
206
|
+
readBuffer(value: string | URL, options: ReadBufferOptions): Promise<Buffer | null> | Buffer | null;
|
|
207
|
+
readBuffer(value: string | URL, cache?: boolean): Buffer | null;
|
|
208
|
+
resolveMime(data: string | Buffer | Uint8Array | ArrayBuffer): Promise<FileTypeResult | undefined>;
|
|
209
|
+
lookupMime(value: string, extension?: boolean): string;
|
|
210
|
+
initCpuUsage(instance?: IModule): CpuUsage;
|
|
211
|
+
getCpuUsage(start: CpuUsage, format: true): string;
|
|
212
|
+
getCpuUsage(start: CpuUsage, format?: boolean): number;
|
|
213
|
+
getMemUsage(format: true): string;
|
|
214
|
+
getMemUsage(format?: boolean): number;
|
|
215
|
+
formatCpuMem(start: CpuUsage, all?: boolean): string;
|
|
216
|
+
getPackageVersion(name: string | [string, string], startDir: string, baseDir?: string): string;
|
|
217
|
+
getPackageVersion(name: string | [string, string], unstable?: boolean, startDir?: string, baseDir?: string): string;
|
|
218
|
+
checkSemVer(name: string | [string, string], options: CheckSemVerOptions): boolean;
|
|
219
|
+
checkSemVer(name: string | [string, string], min: number | string, max: number | string, options: CheckSemVerOptions): boolean;
|
|
220
|
+
checkSemVer(name: string | [string, string], min: number | string, max?: number | string, unstable?: boolean, startDir?: string): boolean;
|
|
221
|
+
sanitizeCmd(value: string): string;
|
|
222
|
+
sanitizeArgs(value: string, doubleQuote?: boolean): string;
|
|
223
|
+
sanitizeArgs(values: string[], doubleQuote?: boolean): string[];
|
|
224
|
+
purgeMemory(percent: number, parent: boolean | number): Promise<number>;
|
|
225
|
+
purgeMemory(percent?: number, limit?: number, parent?: boolean | number): Promise<number>;
|
|
226
|
+
canWrite(name: "temp" | "home"): boolean;
|
|
227
|
+
loadSettings(settings: Settings, password?: string): boolean;
|
|
228
|
+
readonly prototype: IModule<IHost>;
|
|
229
|
+
new(): IModule<IHost>;
|
|
230
|
+
}
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
## References
|
|
234
|
+
|
|
235
|
+
- https://www.unpkg.com/@e-mc/types@0.8.15/lib/core.d.ts
|
|
236
|
+
- https://www.unpkg.com/@e-mc/types@0.8.15/lib/logger.d.ts
|
|
237
|
+
- https://www.unpkg.com/@e-mc/types@0.8.15/lib/module.d.ts
|
|
238
|
+
- https://www.unpkg.com/@e-mc/types@0.8.15/lib/node.d.ts
|
|
239
|
+
|
|
240
|
+
## LICENSE
|
|
241
|
+
|
|
242
242
|
MIT
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ModuleConstructor } from '../types/lib';
|
|
2
|
-
|
|
3
|
-
declare const Module: ModuleConstructor;
|
|
4
|
-
|
|
1
|
+
import type { ModuleConstructor } from '../types/lib';
|
|
2
|
+
|
|
3
|
+
declare const Module: ModuleConstructor;
|
|
4
|
+
|
|
5
5
|
export = Module;
|
package/index.js
CHANGED
|
@@ -554,7 +554,7 @@ function addCacheItem(map, key, data, cache) {
|
|
|
554
554
|
}
|
|
555
555
|
function checkFunction(value) {
|
|
556
556
|
if (typeof value === 'function') {
|
|
557
|
-
Object.defineProperty(value, "__cjs__", { value: true });
|
|
557
|
+
Object.defineProperty(value, "__cjs__", { value: true, writable: false, enumerable: false });
|
|
558
558
|
return value;
|
|
559
559
|
}
|
|
560
560
|
return null;
|
|
@@ -657,9 +657,16 @@ function applyLogId(options) {
|
|
|
657
657
|
}
|
|
658
658
|
return options;
|
|
659
659
|
}
|
|
660
|
-
function withinDir(value, base) {
|
|
660
|
+
function withinDir(value, base, override = false) {
|
|
661
661
|
value = path.normalize(value);
|
|
662
|
-
|
|
662
|
+
if (PLATFORM_WIN32) {
|
|
663
|
+
value = value.toLowerCase();
|
|
664
|
+
base = ensureDir(base.toLowerCase());
|
|
665
|
+
}
|
|
666
|
+
else {
|
|
667
|
+
base = ensureDir(base);
|
|
668
|
+
}
|
|
669
|
+
return value.startsWith(base) && (value !== base || override);
|
|
663
670
|
}
|
|
664
671
|
function formatPercent(value, precision) {
|
|
665
672
|
if (value <= 0) {
|
|
@@ -707,7 +714,7 @@ class Module extends EventEmitter {
|
|
|
707
714
|
this[_f] = new AbortController();
|
|
708
715
|
this[_g] = null;
|
|
709
716
|
}
|
|
710
|
-
static get VERSION() { return "0.8.
|
|
717
|
+
static get VERSION() { return "0.8.15"; }
|
|
711
718
|
static get LOG_TYPE() { return types_1.LOG_TYPE; }
|
|
712
719
|
static get STATUS_TYPE() { return types_1.STATUS_TYPE; }
|
|
713
720
|
static get MAX_TIMEOUT() { return 2147483647; }
|
|
@@ -1224,40 +1231,34 @@ class Module extends EventEmitter {
|
|
|
1224
1231
|
}
|
|
1225
1232
|
return cacheKey ? (0, types_1.generateUUID)() : '';
|
|
1226
1233
|
}
|
|
1227
|
-
static asHash(data, algorithm,
|
|
1228
|
-
if (!algorithm && !
|
|
1234
|
+
static asHash(data, algorithm, digest) {
|
|
1235
|
+
if (!algorithm && !digest) {
|
|
1229
1236
|
return crypto.createHash("sha256").update(data).digest("hex");
|
|
1230
1237
|
}
|
|
1231
|
-
let options
|
|
1232
|
-
if (
|
|
1233
|
-
options =
|
|
1234
|
-
minLength = 0;
|
|
1235
|
-
}
|
|
1236
|
-
if (typeof algorithm === 'number') {
|
|
1237
|
-
minLength = algorithm;
|
|
1238
|
-
algorithm = undefined;
|
|
1239
|
-
}
|
|
1240
|
-
else if ((0, types_1.isObject)(algorithm)) {
|
|
1241
|
-
options = algorithm;
|
|
1242
|
-
algorithm = undefined;
|
|
1243
|
-
}
|
|
1244
|
-
if (options) {
|
|
1245
|
-
options = { ...options };
|
|
1246
|
-
if ('minLength' in options) {
|
|
1247
|
-
minLength = options.minLength;
|
|
1248
|
-
delete options.minLength;
|
|
1249
|
-
}
|
|
1238
|
+
let options;
|
|
1239
|
+
if ((0, types_1.isObject)(algorithm)) {
|
|
1240
|
+
options = { ...algorithm };
|
|
1250
1241
|
if ('algorithm' in options) {
|
|
1251
1242
|
algorithm = options.algorithm;
|
|
1252
1243
|
delete options.algorithm;
|
|
1253
1244
|
}
|
|
1245
|
+
else {
|
|
1246
|
+
algorithm = undefined;
|
|
1247
|
+
}
|
|
1254
1248
|
if ('digest' in options) {
|
|
1255
1249
|
digest = options.digest;
|
|
1256
1250
|
delete options.digest;
|
|
1257
1251
|
}
|
|
1252
|
+
else {
|
|
1253
|
+
digest = undefined;
|
|
1254
|
+
}
|
|
1255
|
+
}
|
|
1256
|
+
else if ((0, types_1.isObject)(digest)) {
|
|
1257
|
+
options = digest;
|
|
1258
|
+
digest = undefined;
|
|
1258
1259
|
}
|
|
1259
|
-
if (
|
|
1260
|
-
|
|
1260
|
+
else if (typeof digest !== 'string') {
|
|
1261
|
+
digest = undefined;
|
|
1261
1262
|
}
|
|
1262
1263
|
try {
|
|
1263
1264
|
return crypto.createHash(algorithm || "sha256", options).update(data).digest(digest || "hex");
|
|
@@ -2609,7 +2610,7 @@ class Module extends EventEmitter {
|
|
|
2609
2610
|
if (permission && (Module.isFile(uri, 'unc') ? permission.hasUNCRead(path.normalize(uri)) || ownPermissionOnly && !permission.getUNCRead() : path.isAbsolute(uri = path.resolve(uri)) && (permission.hasDiskRead(uri) || ownPermissionOnly && !permission.getDiskRead()))) {
|
|
2610
2611
|
return true;
|
|
2611
2612
|
}
|
|
2612
|
-
return VALUES["permission.home_read"] && withinDir(uri, OS_HOMEDIR);
|
|
2613
|
+
return VALUES["permission.home_read"] && withinDir(uri, OS_HOMEDIR, true);
|
|
2613
2614
|
}
|
|
2614
2615
|
canWrite(uri, options) {
|
|
2615
2616
|
let permission = this.permission, ownPermissionOnly = false;
|
|
@@ -2630,7 +2631,7 @@ class Module extends EventEmitter {
|
|
|
2630
2631
|
if (permission && (Module.isFile(uri, 'unc') ? permission.hasUNCWrite(path.normalize(uri)) || ownPermissionOnly && !permission.getUNCWrite() : path.isAbsolute(uri = path.resolve(uri)) && (permission.hasDiskWrite(uri) || ownPermissionOnly && !permission.getDiskWrite()))) {
|
|
2631
2632
|
return true;
|
|
2632
2633
|
}
|
|
2633
|
-
return VALUES["temp.write"] && withinDir(uri, TEMP_DIR) || VALUES["permission.home_write"] && withinDir(uri, OS_HOMEDIR);
|
|
2634
|
+
return VALUES["temp.write"] && withinDir(uri, TEMP_DIR, true) || VALUES["permission.home_write"] && withinDir(uri, OS_HOMEDIR, true);
|
|
2634
2635
|
}
|
|
2635
2636
|
readFile(src, options = {}, callback) {
|
|
2636
2637
|
let promises, outSrc;
|
package/lib-v4.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { IModuleLibV4 } from '../types/lib/compat-v4';
|
|
2
|
-
|
|
3
|
-
declare const LibV4: IModuleLibV4;
|
|
4
|
-
|
|
1
|
+
import type { IModuleLibV4 } from '../types/lib/compat-v4';
|
|
2
|
+
|
|
3
|
+
declare const LibV4: IModuleLibV4;
|
|
4
|
+
|
|
5
5
|
export = LibV4;
|
package/package.json
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@e-mc/module",
|
|
3
|
-
"version": "0.8.
|
|
4
|
-
"description": "Module base class for E-mc.",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"types": "index.d.ts",
|
|
7
|
-
"publishConfig": {
|
|
8
|
-
"access": "public"
|
|
9
|
-
},
|
|
10
|
-
"repository": {
|
|
11
|
-
"type": "git",
|
|
12
|
-
"url": "git+https://github.com/anpham6/e-mc.git",
|
|
13
|
-
"directory": "src/module"
|
|
14
|
-
},
|
|
15
|
-
"keywords": [
|
|
16
|
-
"squared",
|
|
17
|
-
"squared-functions"
|
|
18
|
-
],
|
|
19
|
-
"author": "An Pham <anpham6@gmail.com>",
|
|
20
|
-
"license": "MIT",
|
|
21
|
-
"homepage": "https://github.com/anpham6/e-mc#readme",
|
|
22
|
-
"dependencies": {
|
|
23
|
-
"@e-mc/types": "0.8.
|
|
24
|
-
"abort-controller": "^3.0.0",
|
|
25
|
-
"chalk": "4.1.2",
|
|
26
|
-
"event-target-shim": "^5.0.1",
|
|
27
|
-
"file-type": "16.5.4",
|
|
28
|
-
"js-yaml": "^4.1.0",
|
|
29
|
-
"mime-types": "^2.1.35",
|
|
30
|
-
"picomatch": "^3.0.1",
|
|
31
|
-
"strip-ansi": "6.0.1"
|
|
32
|
-
}
|
|
33
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@e-mc/module",
|
|
3
|
+
"version": "0.8.15",
|
|
4
|
+
"description": "Module base class for E-mc.",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"types": "index.d.ts",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/anpham6/e-mc.git",
|
|
13
|
+
"directory": "src/module"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"squared",
|
|
17
|
+
"squared-functions"
|
|
18
|
+
],
|
|
19
|
+
"author": "An Pham <anpham6@gmail.com>",
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"homepage": "https://github.com/anpham6/e-mc#readme",
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@e-mc/types": "0.8.15",
|
|
24
|
+
"abort-controller": "^3.0.0",
|
|
25
|
+
"chalk": "4.1.2",
|
|
26
|
+
"event-target-shim": "^5.0.1",
|
|
27
|
+
"file-type": "16.5.4",
|
|
28
|
+
"js-yaml": "^4.1.0",
|
|
29
|
+
"mime-types": "^2.1.35",
|
|
30
|
+
"picomatch": "^3.0.1",
|
|
31
|
+
"strip-ansi": "6.0.1"
|
|
32
|
+
}
|
|
33
|
+
}
|