@idlebox/node 1.2.12 → 1.2.14

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.
Files changed (51) hide show
  1. package/lib/index.generated.cjs.map +1 -1
  2. package/lib/index.generated.js.map +1 -1
  3. package/{dist → lib}/node-alpha.d.ts +0 -0
  4. package/{dist → lib}/node-beta.d.ts +0 -0
  5. package/{dist → lib}/node-public.d.ts +0 -0
  6. package/{dist → lib}/node.d.ts +0 -0
  7. package/lib/preload.cjs +3 -0
  8. package/lib/preload.cjs.map +1 -0
  9. package/lib/preload.js +2 -0
  10. package/lib/preload.js.map +1 -0
  11. package/{dist → lib}/tsdoc-metadata.json +1 -1
  12. package/package.json +18 -17
  13. package/src/asyncLoad.ts +32 -0
  14. package/src/child_process/error.ts +63 -0
  15. package/src/child_process/execa.ts +108 -0
  16. package/src/child_process/lateError.ts +53 -0
  17. package/src/child_process/respawn.ts +132 -0
  18. package/src/cli-io/output.ts +3 -0
  19. package/src/crypto/md5.ts +8 -0
  20. package/src/crypto/sha256.ts +8 -0
  21. package/src/environment/findBinary.ts +13 -0
  22. package/src/environment/getEnvironment.ts +56 -0
  23. package/src/environment/npmConfig.ts +15 -0
  24. package/src/environment/pathEnvironment.ts +45 -0
  25. package/src/error/code.ts +124 -0
  26. package/src/error/pretty.ts +240 -0
  27. package/src/events/dumpEventEmitter.ts +9 -0
  28. package/src/fs/commandExists.ts +48 -0
  29. package/src/fs/exists.ts +17 -0
  30. package/src/fs/tempFolder.ts +54 -0
  31. package/src/fs/weiteChanged.ts +46 -0
  32. package/src/index.generated.ts +133 -0
  33. package/src/log/terminal.ts +41 -0
  34. package/src/path-resolve/findPackageRoot.ts +20 -0
  35. package/src/path-resolve/findUp.ts +34 -0
  36. package/src/path-resolve/getAllUp.ts +15 -0
  37. package/src/path-resolve/lrelative.ts +20 -0
  38. package/src/path-resolve/nodeResolvePathArray.ts +10 -0
  39. package/src/path-resolve/resolvePath.ts +43 -0
  40. package/src/preload.ts +1 -0
  41. package/src/stream/blackHoleStream.ts +7 -0
  42. package/src/stream/collectingStream.ts +85 -0
  43. package/src/stream/disposableStream.ts +24 -0
  44. package/src/stream/drainStream.ts +19 -0
  45. package/src/stream/loggerStream.ts +61 -0
  46. package/src/stream/streamPromise.ts +23 -0
  47. package/src/tsconfig.json +14 -0
  48. package/docs/node.api.json +0 -7222
  49. package/docs/node.api.md +0 -666
  50. package/docs/package-public.d.ts +0 -380
  51. package/docs/tsdoc-metadata.json +0 -11
@@ -0,0 +1,124 @@
1
+ export enum ERRNO_LINUX {
2
+ EPERM = 1 /* Not super-user */,
3
+ ENOENT = 2 /* No such file or directory */,
4
+ ESRCH = 3 /* No such process */,
5
+ EINTR = 4 /* Interrupted system call */,
6
+ EIO = 5 /* I/O error */,
7
+ ENXIO = 6 /* No such device or address */,
8
+ E2BIG = 7 /* Arg list too long */,
9
+ ENOEXEC = 8 /* Exec format error */,
10
+ EBADF = 9 /* Bad file number */,
11
+ ECHILD = 10 /* No children */,
12
+ EAGAIN = 11 /* No more processes */,
13
+ ENOMEM = 12 /* Not enough core */,
14
+ EACCES = 13 /* Permission denied */,
15
+ EFAULT = 14 /* Bad address */,
16
+ ENOTBLK = 15 /* Block device required */,
17
+ EBUSY = 16 /* Mount device busy */,
18
+ EEXIST = 17 /* File exists */,
19
+ EXDEV = 18 /* Cross-device link */,
20
+ ENODEV = 19 /* No such device */,
21
+ ENOTDIR = 20 /* Not a directory */,
22
+ EISDIR = 21 /* Is a directory */,
23
+ EINVAL = 22 /* Invalid argument */,
24
+ ENFILE = 23 /* Too many open files in system */,
25
+ EMFILE = 24 /* Too many open files */,
26
+ ENOTTY = 25 /* Not a typewriter */,
27
+ ETXTBSY = 26 /* Text file busy */,
28
+ EFBIG = 27 /* File too large */,
29
+ ENOSPC = 28 /* No space left on device */,
30
+ ESPIPE = 29 /* Illegal seek */,
31
+ EROFS = 30 /* Read only file system */,
32
+ EMLINK = 31 /* Too many links */,
33
+ EPIPE = 32 /* Broken pipe */,
34
+ EDOM = 33 /* Math arg out of domain of func */,
35
+ ERANGE = 34 /* Math result not representable */,
36
+ ENOMSG = 35 /* No message of desired type */,
37
+ EIDRM = 36 /* Identifier removed */,
38
+ ECHRNG = 37 /* Channel number out of range */,
39
+ EL2NSYNC = 38 /* Level 2 not synchronized */,
40
+ EL3HLT = 39 /* Level 3 halted */,
41
+ EL3RST = 40 /* Level 3 reset */,
42
+ ELNRNG = 41 /* Link number out of range */,
43
+ EUNATCH = 42 /* Protocol driver not attached */,
44
+ ENOCSI = 43 /* No CSI structure available */,
45
+ EL2HLT = 44 /* Level 2 halted */,
46
+ EDEADLK = 45 /* Deadlock condition */,
47
+ ENOLCK = 46 /* No record locks available */,
48
+ EBADE = 50 /* Invalid exchange */,
49
+ EBADR = 51 /* Invalid request descriptor */,
50
+ EXFULL = 52 /* Exchange full */,
51
+ ENOANO = 53 /* No anode */,
52
+ EBADRQC = 54 /* Invalid request code */,
53
+ EBADSLT = 55 /* Invalid slot */,
54
+ EDEADLOCK = 56 /* File locking deadlock error */,
55
+ EBFONT = 57 /* Bad font file fmt */,
56
+ ENOSTR = 60 /* Device not a stream */,
57
+ ENODATA = 61 /* No data (for no delay io) */,
58
+ ETIME = 62 /* Timer expired */,
59
+ ENOSR = 63 /* Out of streams resources */,
60
+ ENONET = 64 /* Machine is not on the network */,
61
+ ENOPKG = 65 /* Package not installed */,
62
+ EREMOTE = 66 /* The object is remote */,
63
+ ENOLINK = 67 /* The link has been severed */,
64
+ EADV = 68 /* Advertise error */,
65
+ ESRMNT = 69 /* Srmount error */,
66
+ ECOMM = 70 /* Communication error on send */,
67
+ EPROTO = 71 /* Protocol error */,
68
+ EMULTIHOP = 74 /* Multihop attempted */,
69
+ ELBIN = 75 /* Inode is remote (not really error) */,
70
+ EDOTDOT = 76 /* Cross mount point (not really error) */,
71
+ EBADMSG = 77 /* Trying to read unreadable message */,
72
+ EFTYPE = 79 /* Inappropriate file type or format */,
73
+ ENOTUNIQ = 80 /* Given log. name not unique */,
74
+ EBADFD = 81 /* f.d. invalid for this operation */,
75
+ EREMCHG = 82 /* Remote address changed */,
76
+ ELIBACC = 83 /* Can't access a needed shared lib */,
77
+ ELIBBAD = 84 /* Accessing a corrupted shared lib */,
78
+ ELIBSCN = 85 /* .lib section in a.out corrupted */,
79
+ ELIBMAX = 86 /* Attempting to link in too many libs */,
80
+ ELIBEXEC = 87 /* Attempting to exec a shared library */,
81
+ ENOSYS = 88 /* Function not implemented */,
82
+ ENMFILE = 89 /* No more files */,
83
+ ENOTEMPTY = 90 /* Directory not empty */,
84
+ ENAMETOOLONG = 91 /* File or path name too long */,
85
+ ELOOP = 92 /* Too many symbolic links */,
86
+ EOPNOTSUPP = 95 /* Operation not supported on transport endpoint */,
87
+ EPFNOSUPPORT = 96 /* Protocol family not supported */,
88
+ ECONNRESET = 104 /* Connection reset by peer */,
89
+ ENOBUFS = 105 /* No buffer space available */,
90
+ EAFNOSUPPORT = 106 /* Address family not supported by protocol family */,
91
+ EPROTOTYPE = 107 /* Protocol wrong type for socket */,
92
+ ENOTSOCK = 108 /* Socket operation on non-socket */,
93
+ ENOPROTOOPT = 109 /* Protocol not available */,
94
+ ESHUTDOWN = 110 /* Can't send after socket shutdown */,
95
+ ECONNREFUSED = 111 /* Connection refused */,
96
+ EADDRINUSE = 112 /* Address already in use */,
97
+ ECONNABORTED = 113 /* Connection aborted */,
98
+ ENETUNREACH = 114 /* Network is unreachable */,
99
+ ENETDOWN = 115 /* Network interface is not configured */,
100
+ ETIMEDOUT = 116 /* Connection timed out */,
101
+ EHOSTDOWN = 117 /* Host is down */,
102
+ EHOSTUNREACH = 118 /* Host is unreachable */,
103
+ EINPROGRESS = 119 /* Connection already in progress */,
104
+ EALREADY = 120 /* Socket already connected */,
105
+ EDESTADDRREQ = 121 /* Destination address required */,
106
+ EMSGSIZE = 122 /* Message too long */,
107
+ EPROTONOSUPPORT = 123 /* Unknown protocol */,
108
+ ESOCKTNOSUPPORT = 124 /* Socket type not supported */,
109
+ EADDRNOTAVAIL = 125 /* Address not available */,
110
+ ENETRESET = 126,
111
+ EISCONN = 127 /* Socket is already connected */,
112
+ ENOTCONN = 128 /* Socket is not connected */,
113
+ ETOOMANYREFS = 129,
114
+ EPROCLIM = 130,
115
+ EUSERS = 131,
116
+ EDQUOT = 132,
117
+ ESTALE = 133,
118
+ ENOTSUP = 134 /* Not supported */,
119
+ ENOMEDIUM = 135 /* No medium (in tape drive) */,
120
+ ENOSHARE = 136 /* No such host or network path */,
121
+ ECASECLASH = 137 /* Filename exists with different case */,
122
+ EILSEQ = 138,
123
+ EOVERFLOW = 139 /* Value too large for defined data type */,
124
+ }
@@ -0,0 +1,240 @@
1
+ import { isAbsolute } from '@idlebox/common';
2
+ import { relativePath } from '../path-resolve/resolvePath';
3
+
4
+ const regNormal = /^\s+at ([^\/\s]+)(?: \[as ([^\]]+)])? \(((?:node|file):\/*)?([^:]+)(:\d+)?(:\d+)\)$/;
5
+
6
+ const enum regNormalMatch {
7
+ fn = 1,
8
+ fnAlias,
9
+ fileSchema,
10
+ file,
11
+ row,
12
+ column,
13
+ }
14
+
15
+ const regFunctionOnly = /^\s+at ([^\/\\\s]+(?: \[as ([^\]]+)])?)$/;
16
+
17
+ const enum regFunctionMatch {
18
+ fn = 1,
19
+ fnAlias,
20
+ }
21
+
22
+ const regFileOnly = /^\s+at ([^:]+)(:\d+)?(:\d+)$/;
23
+
24
+ const enum regFileOnlyMatch {
25
+ file = 1,
26
+ row,
27
+ column,
28
+ }
29
+
30
+ const regSimpleFrame = /^\s+at ([^(]+) \(<anonymous>\)$/;
31
+
32
+ const enum regSimpleFrameMatch {
33
+ fn = 1,
34
+ }
35
+
36
+ let root = process.cwd();
37
+
38
+ export function setErrorLogRoot(_root: string) {
39
+ root = _root;
40
+ }
41
+
42
+ interface IInternalData {
43
+ raw?: string;
44
+ fn?: string;
45
+ as?: string;
46
+ file?: string;
47
+ fileSchema?: string; // 'node' | 'file';
48
+ line?: number;
49
+ col?: number;
50
+ abs?: boolean;
51
+ }
52
+
53
+ let notify_printed = false;
54
+ export function prettyPrintError(type: string, e: Error) {
55
+ if (process.env.DISABLE_PRETTY_ERROR) {
56
+ console.error('[${type}] %s', e.stack || e.message);
57
+ return;
58
+ }
59
+ console.error(`------------------------------------------
60
+ [${type}] ${prettyFormatError(e)}`);
61
+
62
+ if (!notify_printed) {
63
+ notify_printed = true;
64
+ console.error('\x1B[2muse env.DISABLE_PRETTY_ERROR=yes to see original error stack\x1B[0m');
65
+ }
66
+ }
67
+
68
+ function red(s: string) {
69
+ return `\x1B[38;5;9m${s}\x1B[0m`;
70
+ }
71
+
72
+ export function prettyFormatError(e: Error) {
73
+ if (!e || !e.message) {
74
+ return red('Unknown Error') + '\n' + new Error().stack?.split('\n').slice(3).join('\n');
75
+ }
76
+ if (!e.stack) {
77
+ return red(e.message + '\nNo stack trace');
78
+ }
79
+ const stackStr = e.stack.replace(/file:\/\//, '').split(/\n/g);
80
+ debugger;
81
+ let first = stackStr.shift()!;
82
+ const stack: IInternalData[] = stackStr.map((line) => {
83
+ if (regNormal.test(line)) {
84
+ const m = regNormal.exec(line)!;
85
+ return {
86
+ fn: m[regNormalMatch.fn],
87
+ as: m[regNormalMatch.fnAlias],
88
+ fileSchema: m[regNormalMatch.fileSchema],
89
+ file: m[regNormalMatch.file],
90
+ line: parseInt(m[regNormalMatch.row].slice(1)),
91
+ col: parseInt(m[regNormalMatch.column].slice(1)),
92
+ abs: isAbsolute(m[regNormalMatch.file]),
93
+ };
94
+ } else if (regFunctionOnly.test(line)) {
95
+ const m = regFunctionOnly.exec(line)!;
96
+ return {
97
+ fn: m[regFunctionMatch.fn],
98
+ as: m[regFunctionMatch.fnAlias],
99
+ file: undefined,
100
+ line: undefined,
101
+ col: undefined,
102
+ abs: false,
103
+ };
104
+ } else if (regFileOnly.test(line)) {
105
+ const m = regFileOnly.exec(line)!;
106
+ return {
107
+ fn: undefined,
108
+ as: undefined,
109
+ file: m[regFileOnlyMatch.file],
110
+ line: parseInt(m[regFileOnlyMatch.row].slice(1)),
111
+ col: parseInt(m[regFileOnlyMatch.column].slice(1)),
112
+ abs: isAbsolute(m[regFileOnlyMatch.file]),
113
+ };
114
+ } else if (regSimpleFrame.test(line)) {
115
+ const m = regSimpleFrame.exec(line)!;
116
+ return {
117
+ fn: m[regSimpleFrameMatch.fn],
118
+ as: undefined,
119
+ file: '<anonymous>',
120
+ line: undefined,
121
+ col: undefined,
122
+ abs: false,
123
+ };
124
+ } else {
125
+ return { raw: line.replace(/^ /, '') };
126
+ }
127
+ });
128
+ const stackOutput = stack
129
+ .filter(ignoreSomeFiles)
130
+ .map(translateFunction)
131
+ .map(({ raw, fn, file, as, abs, line, col, fileSchema }) => {
132
+ let ret;
133
+ if (raw) {
134
+ return raw;
135
+ }
136
+
137
+ if (abs) {
138
+ const isNodeModule = file?.includes('/node_modules/');
139
+ const color = fn ? (isNodeModule ? '4' : '14') : '8';
140
+ ret = ` at \x1b[38;5;${color}m`;
141
+ if (as && fn && fn.startsWith('Object.')) {
142
+ ret += as + ' [export]';
143
+ } else {
144
+ ret += formatFunctionName(fn, as);
145
+ }
146
+ ret += '\x1b[0m';
147
+ if (file) {
148
+ ret += ' (';
149
+ if (!isNodeModule) {
150
+ ret += '\x1b[38;5;2m';
151
+ }
152
+ ret += formatFileLine(fileSchema, file, line, col);
153
+ ret += '\x1B[0m)';
154
+ }
155
+ } else {
156
+ ret = '\x1B[2m at ';
157
+ if (fn) {
158
+ ret += fn;
159
+ }
160
+ if (file) {
161
+ if (fn) {
162
+ ret += ' (';
163
+ }
164
+ ret += formatFileLine(fileSchema, file, line, col);
165
+ if (fn) {
166
+ ret += ')';
167
+ }
168
+ }
169
+ ret += '\x1B[0m';
170
+ }
171
+ return ret;
172
+ });
173
+
174
+ if ((e as any).code) {
175
+ first = first.replace(/^(\S+):/, (_, name) => {
176
+ return `${name}(code ${(e as any).code}):`;
177
+ });
178
+ }
179
+
180
+ return first + '\n' + stackOutput.join('\n');
181
+ }
182
+
183
+ function formatFileLine(schema: string | undefined, file: string, row?: number, col?: number) {
184
+ let rel = file;
185
+
186
+ if (schema !== 'node:') {
187
+ rel = relativePath(root, file);
188
+ if (rel.startsWith('..')) {
189
+ rel = file;
190
+ } else if (!rel.startsWith('.')) {
191
+ rel = './' + rel;
192
+ }
193
+ }
194
+
195
+ return `${schema || ''}${rel}${row ? `:${row}` : ''}${col ? `:${col}` : ''}`;
196
+ }
197
+
198
+ function formatFunctionName(fn?: string, as?: string) {
199
+ if (fn) {
200
+ if (as) {
201
+ return `${fn} [as ${as}]`;
202
+ } else {
203
+ return fn;
204
+ }
205
+ } else {
206
+ return '[anonymous]';
207
+ }
208
+ }
209
+
210
+ function translateFunction(data: IInternalData): IInternalData {
211
+ if (!data.fn) {
212
+ return data;
213
+ }
214
+ if (data.fn === 'Timeout._onTimeout') {
215
+ data.fn = 'setTimeout';
216
+ }
217
+ if (data.fn.startsWith('Timeout.') && data.as === '_onTimeout') {
218
+ data.fn = 'setTimeout->' + data.fn.slice(8);
219
+ delete data.as;
220
+ }
221
+ return data;
222
+ }
223
+
224
+ function ignoreSomeFiles({ file }: IInternalData): boolean {
225
+ if (!file) {
226
+ return true;
227
+ }
228
+ if (file === 'internal/timers.js') {
229
+ return false;
230
+ }
231
+ if (file.startsWith('internal/modules/cjs/loader')) {
232
+ return false;
233
+ }
234
+ if (!file.includes('/')) {
235
+ if (file.startsWith('_stream_')) {
236
+ return false;
237
+ }
238
+ }
239
+ return true;
240
+ }
@@ -0,0 +1,9 @@
1
+ import { EventEmitter } from 'events';
2
+
3
+ export function dumpEventEmitterEmit(ev: EventEmitter) {
4
+ const real = ev.emit;
5
+ ev.emit = (event: string | symbol, ...args: any[]) => {
6
+ console.log('[%s] emit:', ev.constructor.name, ...args);
7
+ return real.call(ev, event, ...args);
8
+ };
9
+ }
@@ -0,0 +1,48 @@
1
+ import { isWindows } from '@idlebox/common';
2
+ import { access, constants, accessSync } from 'fs';
3
+ import { PathEnvironment } from '../environment/pathEnvironment';
4
+
5
+ const windowsExecExtensions = ['.exe', '.bat', '.cmd', '.com', '.ps1'];
6
+
7
+ function exts(alterExt?: string[]) {
8
+ if (alterExt) {
9
+ const ret = [...alterExt];
10
+ if (!isWindows) {
11
+ ret.unshift('');
12
+ }
13
+ return ret;
14
+ }
15
+ if (isWindows) {
16
+ return windowsExecExtensions;
17
+ } else {
18
+ return [''];
19
+ }
20
+ }
21
+
22
+ export async function commandInPath(cmd: string, alterExt?: string[]): Promise<string | undefined> {
23
+ const pathVar = new PathEnvironment();
24
+ for (const item of pathVar.join(cmd)) {
25
+ for (const ext of exts(alterExt)) {
26
+ const found = await new Promise((resolve) => {
27
+ access(item + ext, constants.X_OK, (e) => {
28
+ if (e) resolve(false);
29
+ else resolve(true);
30
+ });
31
+ });
32
+ if (found) return item + ext;
33
+ }
34
+ }
35
+ return undefined;
36
+ }
37
+ export function commmandInPathSync(cmd: string, alterExt?: string[]): string | undefined {
38
+ const pathVar = new PathEnvironment();
39
+ for (const item of pathVar.join(cmd)) {
40
+ for (const ext of exts(alterExt)) {
41
+ try {
42
+ accessSync(item + ext, constants.X_OK);
43
+ return item + ext;
44
+ } catch {}
45
+ }
46
+ }
47
+ return undefined;
48
+ }
@@ -0,0 +1,17 @@
1
+ import { access, accessSync } from 'fs';
2
+
3
+ export function existsSync(path: string): boolean {
4
+ try {
5
+ accessSync(path);
6
+ return true;
7
+ } catch (e) {
8
+ return false;
9
+ }
10
+ }
11
+
12
+ export function exists(path: string): Promise<boolean> {
13
+ return new Promise((resolve) => {
14
+ const wrappedCallback = (err: Error | null) => (err ? resolve(false) : resolve(true));
15
+ access(path, wrappedCallback);
16
+ });
17
+ }
@@ -0,0 +1,54 @@
1
+ import { mkdirSync, readdirSync, rmdirSync, statSync, unlinkSync } from 'fs';
2
+ import { resolve } from 'path';
3
+ import { IDisposable } from '@idlebox/common';
4
+ import { existsSync } from './exists';
5
+
6
+ let registered = false;
7
+ const tempFolders = new Set<string>();
8
+
9
+ export function createTempFolder(fullPath: string): IDisposable {
10
+ if (existsSync(fullPath)) {
11
+ throw new Error('temp folder already exists: ' + fullPath);
12
+ }
13
+ if (!registered) {
14
+ process.on('beforeExit', onBeforeExit);
15
+ }
16
+ tempFolders.add(fullPath);
17
+ mkdirSync(fullPath);
18
+
19
+ return {
20
+ dispose() {
21
+ tempFolders.delete(fullPath);
22
+ rmdirpSync(fullPath);
23
+ },
24
+ };
25
+ }
26
+
27
+ function rmdirpSync(p: string) {
28
+ try {
29
+ const stat = statSync(p);
30
+ if (stat.isSymbolicLink() || stat.isFile()) {
31
+ unlinkSync(p);
32
+ } else if (stat.isDirectory()) {
33
+ let succ = true;
34
+ for (const item of readdirSync(p)) {
35
+ if (!rmdirpSync(resolve(p, item))) {
36
+ succ = false;
37
+ }
38
+ }
39
+ if (succ) {
40
+ rmdirSync(p);
41
+ }
42
+ return succ;
43
+ }
44
+ return true;
45
+ } catch {
46
+ return false;
47
+ }
48
+ }
49
+
50
+ function onBeforeExit() {
51
+ for (const path of tempFolders) {
52
+ rmdirpSync(path);
53
+ }
54
+ }
@@ -0,0 +1,46 @@
1
+ import { readFile as readFileAsync, readFileSync, writeFile as writeFileAsync, writeFileSync } from 'fs';
2
+ import { promisify } from 'util';
3
+ import { exists, existsSync } from './exists';
4
+
5
+ const readFile = promisify(readFileAsync);
6
+ const writeFile = promisify(writeFileAsync);
7
+
8
+ export function writeFileIfChangeSync(file: string, data: string | Buffer) {
9
+ if (existsSync(file)) {
10
+ if (typeof data === 'string') {
11
+ if (readFileSync(file, 'utf-8') === data) {
12
+ return false;
13
+ }
14
+ } else {
15
+ if (Buffer.compare(data, readFileSync(file)) === 0) {
16
+ return false;
17
+ }
18
+ }
19
+ }
20
+ if (typeof data === 'string') {
21
+ writeFileSync(file, data, 'utf-8');
22
+ } else {
23
+ writeFileSync(file, data);
24
+ }
25
+ return true;
26
+ }
27
+
28
+ export async function writeFileIfChange(file: string, data: string | Buffer) {
29
+ if (await exists(file)) {
30
+ if (typeof data === 'string') {
31
+ if ((await readFile(file, 'utf-8')) === data) {
32
+ return false;
33
+ }
34
+ } else {
35
+ if (Buffer.compare(data, await readFile(file)) === 0) {
36
+ return false;
37
+ }
38
+ }
39
+ }
40
+ if (typeof data === 'string') {
41
+ await writeFile(file, data, 'utf-8');
42
+ } else {
43
+ await writeFile(file, data);
44
+ }
45
+ return true;
46
+ }
@@ -0,0 +1,133 @@
1
+ // DO NOT EDIT THIS FILE
2
+ // @ts-ignore
3
+ /* eslint-disable */
4
+
5
+ /* preload.ts */
6
+ // Identifiers
7
+ /* path-resolve/resolvePath.ts */
8
+ // Identifiers
9
+ export {ResolvePathFunction} from "./path-resolve/resolvePath";
10
+ export {JoinPathFunction} from "./path-resolve/resolvePath";
11
+ export {resolvePath} from "./path-resolve/resolvePath";
12
+ export {NormalizePathFunction} from "./path-resolve/resolvePath";
13
+ export {normalizePath} from "./path-resolve/resolvePath";
14
+ export {osTempDir} from "./path-resolve/resolvePath";
15
+ export {relativePath} from "./path-resolve/resolvePath";
16
+ /* error/pretty.ts */
17
+ // Identifiers
18
+ export {setErrorLogRoot} from "./error/pretty";
19
+ export {prettyPrintError} from "./error/pretty";
20
+ export {prettyFormatError} from "./error/pretty";
21
+ /* asyncLoad.ts */
22
+ // Identifiers
23
+ export {AsyncMainFunction} from "./asyncLoad";
24
+ export {ExitError} from "./asyncLoad";
25
+ export {runMain} from "./asyncLoad";
26
+ /* child_process/error.ts */
27
+ // Identifiers
28
+ export {checkChildProcessResult} from "./child_process/error";
29
+ /* child_process/execa.ts */
30
+ // Identifiers
31
+ export {Sync} from "./child_process/execa";
32
+ export {Async} from "./child_process/execa";
33
+ export {ICommand} from "./child_process/execa";
34
+ export {spawnWithoutOutput} from "./child_process/execa";
35
+ export {spawnGetOutput} from "./child_process/execa";
36
+ export {spawnGetEverything} from "./child_process/execa";
37
+ /* cli-io/output.ts */
38
+ // Identifiers
39
+ export {printLine} from "./cli-io/output";
40
+ /* child_process/lateError.ts */
41
+ // Identifiers
42
+ export {ISpawnAdditionOptions} from "./child_process/lateError";
43
+ export {execLazyError} from "./child_process/lateError";
44
+ /* fs/exists.ts */
45
+ // Identifiers
46
+ export {existsSync} from "./fs/exists";
47
+ export {exists} from "./fs/exists";
48
+ /* environment/getEnvironment.ts */
49
+ // Identifiers
50
+ export {IEnvironmentResult} from "./environment/getEnvironment";
51
+ export {getEnvironment} from "./environment/getEnvironment";
52
+ export {deleteEnvironment} from "./environment/getEnvironment";
53
+ export {cleanupEnvironment} from "./environment/getEnvironment";
54
+ /* environment/pathEnvironment.ts */
55
+ // Identifiers
56
+ export {PATH_SEPARATOR} from "./environment/pathEnvironment";
57
+ export {PathEnvironment} from "./environment/pathEnvironment";
58
+ /* environment/findBinary.ts */
59
+ // Identifiers
60
+ export {findBinary} from "./environment/findBinary";
61
+ /* child_process/respawn.ts */
62
+ // Identifiers
63
+ export {spawnRecreateEventHandlers} from "./child_process/respawn";
64
+ export {trySpawnInScope} from "./child_process/respawn";
65
+ export {respawnInScope} from "./child_process/respawn";
66
+ /* crypto/md5.ts */
67
+ // Identifiers
68
+ export {md5} from "./crypto/md5";
69
+ /* crypto/sha256.ts */
70
+ // Identifiers
71
+ export {sha256} from "./crypto/sha256";
72
+ /* environment/npmConfig.ts */
73
+ // Identifiers
74
+ export {getNpmConfigValue} from "./environment/npmConfig";
75
+ /* error/code.ts */
76
+ // Identifiers
77
+ export {ERRNO_LINUX} from "./error/code";
78
+ /* events/dumpEventEmitter.ts */
79
+ // Identifiers
80
+ export {dumpEventEmitterEmit} from "./events/dumpEventEmitter";
81
+ /* fs/commandExists.ts */
82
+ // Identifiers
83
+ export {commandInPath} from "./fs/commandExists";
84
+ export {commmandInPathSync} from "./fs/commandExists";
85
+ /* fs/tempFolder.ts */
86
+ // Identifiers
87
+ export {createTempFolder} from "./fs/tempFolder";
88
+ /* fs/weiteChanged.ts */
89
+ // Identifiers
90
+ export {writeFileIfChangeSync} from "./fs/weiteChanged";
91
+ export {writeFileIfChange} from "./fs/weiteChanged";
92
+ /* log/terminal.ts */
93
+ // Identifiers
94
+ export {WrappedTerminalConsole} from "./log/terminal";
95
+ /* path-resolve/findUp.ts */
96
+ // Identifiers
97
+ export {findUpUntil} from "./path-resolve/findUp";
98
+ export {findUpUntilSync} from "./path-resolve/findUp";
99
+ /* path-resolve/findPackageRoot.ts */
100
+ // Identifiers
101
+ export {findPackageRoot} from "./path-resolve/findPackageRoot";
102
+ /* path-resolve/getAllUp.ts */
103
+ // Identifiers
104
+ export {getAllPathUpToRoot} from "./path-resolve/getAllUp";
105
+ /* path-resolve/lrelative.ts */
106
+ // Identifiers
107
+ export {lrelative} from "./path-resolve/lrelative";
108
+ /* path-resolve/nodeResolvePathArray.ts */
109
+ // Identifiers
110
+ export {nodeResolvePathArray} from "./path-resolve/nodeResolvePathArray";
111
+ /* stream/blackHoleStream.ts */
112
+ // Identifiers
113
+ export {BlackHoleStream} from "./stream/blackHoleStream";
114
+ /* stream/streamPromise.ts */
115
+ // Identifiers
116
+ export {streamPromise} from "./stream/streamPromise";
117
+ export {streamHasEnd} from "./stream/streamPromise";
118
+ /* stream/collectingStream.ts */
119
+ // Identifiers
120
+ export {streamToBuffer} from "./stream/collectingStream";
121
+ export {RawCollectingStream} from "./stream/collectingStream";
122
+ export {CollectingStream} from "./stream/collectingStream";
123
+ /* stream/disposableStream.ts */
124
+ // Identifiers
125
+ export {disposableStream} from "./stream/disposableStream";
126
+ /* stream/drainStream.ts */
127
+ // Identifiers
128
+ export {drainStream} from "./stream/drainStream";
129
+ /* stream/loggerStream.ts */
130
+ // Identifiers
131
+ export {LogFunction} from "./stream/loggerStream";
132
+ export {LoggerStream} from "./stream/loggerStream";
133
+ export {HexDumpLoggerStream} from "./stream/loggerStream";