@appium/support 7.0.4 → 7.0.6
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/build/lib/console.d.ts +42 -88
- package/build/lib/console.d.ts.map +1 -1
- package/build/lib/console.js +25 -85
- package/build/lib/console.js.map +1 -1
- package/build/lib/doctor.d.ts +6 -18
- package/build/lib/doctor.d.ts.map +1 -1
- package/build/lib/doctor.js +0 -15
- package/build/lib/doctor.js.map +1 -1
- package/build/lib/env.d.ts +14 -20
- package/build/lib/env.d.ts.map +1 -1
- package/build/lib/env.js +24 -61
- package/build/lib/env.js.map +1 -1
- package/build/lib/fs.d.ts +109 -148
- package/build/lib/fs.d.ts.map +1 -1
- package/build/lib/fs.js +130 -230
- package/build/lib/fs.js.map +1 -1
- package/build/lib/image-util.d.ts +7 -6
- package/build/lib/image-util.d.ts.map +1 -1
- package/build/lib/image-util.js +9 -6
- package/build/lib/image-util.js.map +1 -1
- package/build/lib/index.d.ts +19 -17
- package/build/lib/index.d.ts.map +1 -1
- package/build/lib/logger.d.ts +1 -1
- package/build/lib/logger.d.ts.map +1 -1
- package/build/lib/logger.js +1 -1
- package/build/lib/logger.js.map +1 -1
- package/build/lib/logging.d.ts +7 -15
- package/build/lib/logging.d.ts.map +1 -1
- package/build/lib/logging.js +36 -62
- package/build/lib/logging.js.map +1 -1
- package/build/lib/mjpeg.d.ts +19 -56
- package/build/lib/mjpeg.d.ts.map +1 -1
- package/build/lib/mjpeg.js +55 -78
- package/build/lib/mjpeg.js.map +1 -1
- package/build/lib/mkdirp.d.ts +4 -1
- package/build/lib/mkdirp.d.ts.map +1 -1
- package/build/lib/mkdirp.js +1 -2
- package/build/lib/mkdirp.js.map +1 -1
- package/build/lib/net.d.ts +52 -90
- package/build/lib/net.d.ts.map +1 -1
- package/build/lib/net.js +104 -193
- package/build/lib/net.js.map +1 -1
- package/build/lib/node.d.ts +16 -17
- package/build/lib/node.d.ts.map +1 -1
- package/build/lib/node.js +115 -120
- package/build/lib/node.js.map +1 -1
- package/build/lib/npm.d.ts +65 -86
- package/build/lib/npm.d.ts.map +1 -1
- package/build/lib/npm.js +64 -122
- package/build/lib/npm.js.map +1 -1
- package/build/lib/plist.d.ts +36 -29
- package/build/lib/plist.d.ts.map +1 -1
- package/build/lib/plist.js +62 -59
- package/build/lib/plist.js.map +1 -1
- package/build/lib/process.d.ts +19 -2
- package/build/lib/process.d.ts.map +1 -1
- package/build/lib/process.js +24 -7
- package/build/lib/process.js.map +1 -1
- package/build/lib/system.d.ts +41 -6
- package/build/lib/system.d.ts.map +1 -1
- package/build/lib/system.js +49 -14
- package/build/lib/system.js.map +1 -1
- package/build/lib/tempdir.d.ts +26 -49
- package/build/lib/tempdir.d.ts.map +1 -1
- package/build/lib/tempdir.js +46 -78
- package/build/lib/tempdir.js.map +1 -1
- package/build/lib/timing.d.ts +28 -22
- package/build/lib/timing.d.ts.map +1 -1
- package/build/lib/timing.js +16 -17
- package/build/lib/timing.js.map +1 -1
- package/build/lib/util.d.ts +164 -181
- package/build/lib/util.d.ts.map +1 -1
- package/build/lib/util.js +198 -253
- package/build/lib/util.js.map +1 -1
- package/build/lib/zip.d.ts +81 -139
- package/build/lib/zip.d.ts.map +1 -1
- package/build/lib/zip.js +235 -283
- package/build/lib/zip.js.map +1 -1
- package/lib/console.ts +139 -0
- package/lib/{doctor.js → doctor.ts} +6 -20
- package/lib/{env.js → env.ts} +34 -62
- package/lib/fs.ts +453 -0
- package/lib/image-util.ts +40 -0
- package/lib/index.ts +1 -0
- package/lib/{logger.js → logger.ts} +1 -1
- package/lib/logging.ts +157 -0
- package/lib/mjpeg.ts +186 -0
- package/lib/{mkdirp.js → mkdirp.ts} +2 -2
- package/lib/net.ts +305 -0
- package/lib/{node.js → node.ts} +136 -135
- package/lib/npm.ts +291 -0
- package/lib/plist.ts +187 -0
- package/lib/process.ts +62 -0
- package/lib/system.ts +95 -0
- package/lib/tempdir.ts +115 -0
- package/lib/{timing.js → timing.ts} +28 -33
- package/lib/util.ts +561 -0
- package/lib/{zip.js → zip.ts} +344 -299
- package/package.json +24 -26
- package/tsconfig.json +3 -5
- package/index.js +0 -1
- package/lib/console.js +0 -173
- package/lib/fs.js +0 -496
- package/lib/image-util.js +0 -32
- package/lib/logging.js +0 -145
- package/lib/mjpeg.js +0 -207
- package/lib/net.js +0 -336
- package/lib/npm.js +0 -310
- package/lib/plist.js +0 -182
- package/lib/process.js +0 -46
- package/lib/system.js +0 -48
- package/lib/tempdir.js +0 -131
- package/lib/util.js +0 -585
package/build/lib/util.d.ts
CHANGED
|
@@ -1,233 +1,216 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
* size must be enough to keep the resulting object (usually this size is
|
|
19
|
-
* limited to 1.4 GB)
|
|
20
|
-
*/
|
|
21
|
-
maxSize?: number | undefined;
|
|
22
|
-
};
|
|
23
|
-
export type LockFileOptions = {
|
|
24
|
-
/**
|
|
25
|
-
* The max time in seconds to wait for the lock
|
|
26
|
-
*/
|
|
27
|
-
timeout?: number | undefined;
|
|
28
|
-
/**
|
|
29
|
-
* Whether to try lock recovery if
|
|
30
|
-
* the first attempt to acquire it timed out.
|
|
31
|
-
*/
|
|
32
|
-
tryRecovery?: boolean | undefined;
|
|
33
|
-
};
|
|
34
|
-
/**
|
|
35
|
-
* A `string` which is never `''`.
|
|
36
|
-
*/
|
|
37
|
-
export type NonEmptyString<T extends string> = T extends "" ? never : T;
|
|
38
|
-
/**
|
|
39
|
-
* return true if the the value is not `undefined`, `null`, or `NaN`.
|
|
1
|
+
import B from 'bluebird';
|
|
2
|
+
import { parse as shellParse } from 'shell-quote';
|
|
3
|
+
export { shellParse };
|
|
4
|
+
export { v1 as uuidV1, v3 as uuidV3, v4 as uuidV4, v5 as uuidV5 } from 'uuid';
|
|
5
|
+
import type { Element } from '@appium/types';
|
|
6
|
+
/** W3C WebDriver element identifier key used in element objects. */
|
|
7
|
+
export declare const W3C_WEB_ELEMENT_IDENTIFIER = "element-6066-11e4-a52e-4f735466cecf";
|
|
8
|
+
/** Size of one kibibyte in bytes (1024). */
|
|
9
|
+
export declare const KiB = 1024;
|
|
10
|
+
/** Size of one mebibyte in bytes (1024 * 1024). */
|
|
11
|
+
export declare const MiB: number;
|
|
12
|
+
/** Size of one gibibyte in bytes (1024 * 1024 * 1024). */
|
|
13
|
+
export declare const GiB: number;
|
|
14
|
+
/** A string which is never `''`. */
|
|
15
|
+
export type NonEmptyString<T extends string = string> = T extends '' ? never : T;
|
|
16
|
+
/**
|
|
17
|
+
* Type guard: returns true if the value is a non-empty string.
|
|
40
18
|
*
|
|
41
|
-
*
|
|
42
|
-
* @
|
|
43
|
-
* @param {T} val
|
|
44
|
-
* @returns {val is NonNullable<T>}
|
|
19
|
+
* @param val - Value to check
|
|
20
|
+
* @returns `true` if `val` is a string with at least one character
|
|
45
21
|
*/
|
|
46
|
-
export function
|
|
22
|
+
export declare function hasContent(val: unknown): val is NonEmptyString;
|
|
47
23
|
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* @
|
|
24
|
+
* Type guard: returns true if the value is not `undefined`, `null`, or `NaN`.
|
|
25
|
+
*
|
|
26
|
+
* @param val - Value to check
|
|
27
|
+
* @returns `true` if `val` is non-null and non-undefined (and not NaN for numbers)
|
|
51
28
|
*/
|
|
52
|
-
export function
|
|
29
|
+
export declare function hasValue<T>(val: T): val is NonNullable<T>;
|
|
53
30
|
/**
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
* @param
|
|
57
|
-
* @returns
|
|
31
|
+
* Escapes spaces in a string for use in command-line arguments (e.g. ` ` → `\ `).
|
|
32
|
+
*
|
|
33
|
+
* @param str - String that may contain spaces
|
|
34
|
+
* @returns String with spaces escaped by a backslash
|
|
58
35
|
*/
|
|
59
|
-
export function
|
|
36
|
+
export declare function escapeSpace(str: string): string;
|
|
60
37
|
/**
|
|
61
|
-
*
|
|
62
|
-
*
|
|
38
|
+
* Escapes special characters in a string (backslash, slash, quotes, control chars).
|
|
39
|
+
* If `quoteEscape` is provided, that character is also escaped.
|
|
40
|
+
*
|
|
41
|
+
* @param str - String to escape, or non-string value (returned unchanged)
|
|
42
|
+
* @param quoteEscape - Optional character to escape, or `false` to skip
|
|
43
|
+
* @returns Escaped string, or original value if `str` is not a string
|
|
63
44
|
*/
|
|
64
|
-
export function
|
|
65
|
-
export function cancellableDelay(ms: any): B<any>;
|
|
66
|
-
export function multiResolve(roots: any, ...args: any[]): any;
|
|
45
|
+
export declare function escapeSpecialChars(str: string | unknown, quoteEscape?: string | false): string | unknown;
|
|
67
46
|
/**
|
|
68
|
-
*
|
|
47
|
+
* Returns the first non-internal IPv4 address of the machine, if any.
|
|
69
48
|
*
|
|
70
|
-
* @
|
|
71
|
-
* @returns {any}
|
|
49
|
+
* @returns The local IPv4 address, or `undefined` if none found
|
|
72
50
|
*/
|
|
73
|
-
export function
|
|
51
|
+
export declare function localIp(): string | undefined;
|
|
74
52
|
/**
|
|
53
|
+
* Creates a promise that resolves after a delay and can be cancelled via `.cancel()`.
|
|
75
54
|
*
|
|
76
|
-
* @param
|
|
77
|
-
* @returns
|
|
55
|
+
* @param ms - Delay in milliseconds before the promise resolves
|
|
56
|
+
* @returns A Bluebird promise with a `cancel()` method; cancel rejects with CancellationError
|
|
78
57
|
*/
|
|
79
|
-
export function
|
|
58
|
+
export declare function cancellableDelay(ms: number): B<void> & {
|
|
59
|
+
cancel: () => void;
|
|
60
|
+
};
|
|
80
61
|
/**
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
* @param
|
|
85
|
-
* @returns
|
|
62
|
+
* Resolves each root path with the given path segments, returning an array of absolute paths.
|
|
63
|
+
*
|
|
64
|
+
* @param roots - Base directory paths to resolve against
|
|
65
|
+
* @param args - Path segments to join with each root (e.g. 'foo', 'bar' → root/foo/bar)
|
|
66
|
+
* @returns Array of absolute paths, one per root
|
|
86
67
|
*/
|
|
87
|
-
export function
|
|
88
|
-
export function filterObject(obj: any, predicate: any): any;
|
|
68
|
+
export declare function multiResolve(roots: string[], ...args: string[]): string[];
|
|
89
69
|
/**
|
|
90
|
-
*
|
|
70
|
+
* Parses a value as JSON if it is a string; otherwise returns the value as-is.
|
|
91
71
|
*
|
|
92
|
-
* @param
|
|
93
|
-
* @returns
|
|
94
|
-
* '1.00 KB' for '1024 B'
|
|
95
|
-
* @throws {Error} If bytes count cannot be converted to an integer or
|
|
96
|
-
* if it is less than zero.
|
|
72
|
+
* @param obj - String (to parse) or other value (returned unchanged)
|
|
73
|
+
* @returns Parsed object or original value
|
|
97
74
|
*/
|
|
98
|
-
export function
|
|
75
|
+
export declare function safeJsonParse<T>(obj: unknown): T;
|
|
99
76
|
/**
|
|
100
|
-
*
|
|
101
|
-
* particular root folder. Both paths can include .. and . specifiers
|
|
77
|
+
* Stringifies an object to JSON, converting Buffers to strings for readable output.
|
|
102
78
|
*
|
|
103
|
-
* @param
|
|
104
|
-
* @param
|
|
105
|
-
* @param
|
|
106
|
-
* @returns
|
|
107
|
-
* @throws {Error} if any of the given paths is not absolute
|
|
79
|
+
* @param obj - Object to serialize
|
|
80
|
+
* @param replacer - Optional replacer function (same as JSON.stringify)
|
|
81
|
+
* @param space - Indentation for pretty-printing. Defaults to 2
|
|
82
|
+
* @returns JSON string
|
|
108
83
|
*/
|
|
109
|
-
export function
|
|
110
|
-
export const W3C_WEB_ELEMENT_IDENTIFIER: "element-6066-11e4-a52e-4f735466cecf";
|
|
84
|
+
export declare function jsonStringify(obj: unknown, replacer?: ((key: string, value: unknown) => unknown) | null, space?: number | string): string;
|
|
111
85
|
/**
|
|
112
|
-
*
|
|
113
|
-
* destination.
|
|
86
|
+
* Extracts the element ID from a W3C or JSONWP element object, or returns the string if already an ID.
|
|
114
87
|
*
|
|
115
|
-
* @param
|
|
116
|
-
* @
|
|
117
|
-
* @param {...string} pathN - Zero or more absolute or relative paths to files/folders
|
|
118
|
-
* @returns {Promise<boolean>} true if all paths are pointing to the same file system item
|
|
88
|
+
* @param el - Element object (with ELEMENT or W3C identifier) or raw element ID string
|
|
89
|
+
* @returns The element ID string
|
|
119
90
|
*/
|
|
120
|
-
export function
|
|
91
|
+
export declare function unwrapElement(el: Element | string): string;
|
|
121
92
|
/**
|
|
122
|
-
*
|
|
93
|
+
* Wraps an element ID string in an element object compatible with both W3C and JSONWP.
|
|
123
94
|
*
|
|
124
|
-
* @param
|
|
125
|
-
*
|
|
126
|
-
* @param {string} ver2 - The second version number to compare. Should be a valid
|
|
127
|
-
* version number supported by semver parser.
|
|
128
|
-
* @param {string} operator - One of supported version number operators:
|
|
129
|
-
* ==, !=, >, <, <=, >=, =
|
|
130
|
-
* @returns {boolean} true or false depending on the actual comparison result
|
|
131
|
-
* @throws {Error} if an unsupported operator is supplied or any of the supplied
|
|
132
|
-
* version strings cannot be coerced
|
|
95
|
+
* @param elementId - The element ID to wrap
|
|
96
|
+
* @returns Element object with both ELEMENT and W3C identifier keys
|
|
133
97
|
*/
|
|
134
|
-
export function
|
|
98
|
+
export declare function wrapElement(elementId: string): Element;
|
|
135
99
|
/**
|
|
136
|
-
*
|
|
100
|
+
* Returns a copy of the object containing only properties that pass the predicate.
|
|
101
|
+
* If the predicate is missing, removes properties whose values are undefined.
|
|
102
|
+
* If the predicate is a scalar, keeps only properties whose value equals that scalar.
|
|
103
|
+
* If the predicate is a function, calls it for each (value, obj) and keeps properties where it returns true.
|
|
137
104
|
*
|
|
138
|
-
* @
|
|
139
|
-
* @param
|
|
140
|
-
* @
|
|
141
|
-
* if `ver` cannot be coerced
|
|
142
|
-
* @returns {Strict extends true ? string : string|null} Coerced version number or null if the string cannot be
|
|
143
|
-
* coerced and strict mode is disabled
|
|
144
|
-
* @throws {Error} if strict mode is enabled and `ver` cannot be coerced
|
|
105
|
+
* @param obj - Source object to filter
|
|
106
|
+
* @param predicate - Optional filter: undefined (drop undefined values), scalar (value match), or function
|
|
107
|
+
* @returns New object with only the properties that pass the predicate
|
|
145
108
|
*/
|
|
146
|
-
export function
|
|
109
|
+
export declare function filterObject<T extends Record<string, unknown>>(obj: T, predicate?: ((value: unknown, obj: T) => boolean) | unknown): Partial<T>;
|
|
147
110
|
/**
|
|
148
|
-
*
|
|
149
|
-
* for more details
|
|
111
|
+
* Converts a byte count to a human-readable size string (e.g. "1.50 MB").
|
|
150
112
|
*
|
|
151
|
-
* @param
|
|
152
|
-
* @returns
|
|
113
|
+
* @param bytes - Number of bytes (or string coercible to a number)
|
|
114
|
+
* @returns Formatted string like "123 B", "1.50 KB", "2.00 MB", "3.00 GB"
|
|
115
|
+
* @throws {Error} If bytes cannot be converted to a non-negative integer
|
|
153
116
|
*/
|
|
154
|
-
export function
|
|
117
|
+
export declare function toReadableSizeString(bytes: number | string): string;
|
|
155
118
|
/**
|
|
156
|
-
*
|
|
157
|
-
* display. This mimics JSON.stringify (see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify)
|
|
158
|
-
* except the `replacer` argument can only be a function.
|
|
119
|
+
* Checks whether the given path is a subpath of the given root folder.
|
|
159
120
|
*
|
|
160
|
-
* @param
|
|
161
|
-
* @param
|
|
162
|
-
*
|
|
163
|
-
* @
|
|
164
|
-
*
|
|
165
|
-
* @returns {string} - the JSON object serialized as a string
|
|
121
|
+
* @param originalPath - The absolute file or folder path to test
|
|
122
|
+
* @param root - The absolute root folder path
|
|
123
|
+
* @param forcePosix - If true, interpret paths in POSIX format (e.g. on Windows)
|
|
124
|
+
* @returns `true` if `originalPath` is under `root`
|
|
125
|
+
* @throws {Error} If either path is not absolute
|
|
166
126
|
*/
|
|
167
|
-
export function
|
|
127
|
+
export declare function isSubPath(originalPath: string, root: string, forcePosix?: boolean | null): boolean;
|
|
168
128
|
/**
|
|
169
|
-
*
|
|
170
|
-
*
|
|
129
|
+
* Checks whether the given paths refer to the same file system entity (same inode).
|
|
130
|
+
* All paths must exist.
|
|
131
|
+
*
|
|
132
|
+
* @param path1 - First path
|
|
133
|
+
* @param path2 - Second path
|
|
134
|
+
* @param pathN - Additional paths to compare
|
|
135
|
+
* @returns `true` if all paths resolve to the same file/directory
|
|
171
136
|
*/
|
|
137
|
+
export declare function isSameDestination(path1: string, path2: string, ...pathN: string[]): Promise<boolean>;
|
|
172
138
|
/**
|
|
173
|
-
*
|
|
139
|
+
* Coerces a value to a valid semver string (e.g. "1.0" → "1.0.0").
|
|
174
140
|
*
|
|
175
|
-
* @param
|
|
176
|
-
* @param
|
|
177
|
-
* @
|
|
178
|
-
*
|
|
179
|
-
* @returns {string} The word pluralized according to the number
|
|
141
|
+
* @param ver - Version string or number to coerce
|
|
142
|
+
* @param strict - If true, throws when coercion fails; if false, returns null
|
|
143
|
+
* @returns Valid semver string, or null when strict is false and coercion fails
|
|
144
|
+
* @throws {Error} When strict is true and ver cannot be coerced
|
|
180
145
|
*/
|
|
181
|
-
export function
|
|
182
|
-
export
|
|
183
|
-
export const MiB: number;
|
|
184
|
-
export const KiB: 1024;
|
|
146
|
+
export declare function coerceVersion(ver: string, strict: true): string;
|
|
147
|
+
export declare function coerceVersion(ver: string, strict?: false): string | null;
|
|
185
148
|
/**
|
|
186
|
-
*
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
*
|
|
190
|
-
*
|
|
191
|
-
*
|
|
149
|
+
* Compares two version strings using the given operator.
|
|
150
|
+
*
|
|
151
|
+
* @param ver1 - First version string
|
|
152
|
+
* @param operator - One of: ==, !=, >, <, >=, <=, =
|
|
153
|
+
* @param ver2 - Second version string
|
|
154
|
+
* @returns `true` if ver1 operator ver2 holds (e.g. "2.0.0" >= "1.0.0")
|
|
155
|
+
* @throws {Error} If operator is unsupported or either version cannot be coerced
|
|
192
156
|
*/
|
|
157
|
+
export declare function compareVersions(ver1: string, operator: string, ver2: string): boolean;
|
|
193
158
|
/**
|
|
194
|
-
*
|
|
195
|
-
* The operation is memory-usage friendly and should be used while encoding
|
|
196
|
-
* large files to base64
|
|
159
|
+
* Quotes and escapes command-line arguments so they can be safely passed to a shell.
|
|
197
160
|
*
|
|
198
|
-
* @param
|
|
199
|
-
* @
|
|
200
|
-
* @returns {Promise<Buffer>} base64-encoded content of the source file as memory buffer
|
|
201
|
-
* @throws {Error} if there was an error while reading the source file
|
|
202
|
-
* or the source file is too
|
|
161
|
+
* @param args - Single argument or array of arguments to quote
|
|
162
|
+
* @returns Quoted string suitable for shell parsing
|
|
203
163
|
*/
|
|
204
|
-
export function
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
164
|
+
export declare function quote(args: string | string[]): string;
|
|
165
|
+
/** Options for pluralize(). */
|
|
166
|
+
export interface PluralizeOptions {
|
|
167
|
+
/** If true, prefix the result with the count (e.g. "3 ducks"). */
|
|
168
|
+
inclusive?: boolean;
|
|
169
|
+
}
|
|
210
170
|
/**
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
* @
|
|
214
|
-
*
|
|
215
|
-
|
|
171
|
+
* Returns the plural or singular form of a word appropriate to the count (e.g. "duck" + 1 → "duck", + 2 → "ducks").
|
|
172
|
+
*
|
|
173
|
+
* @param word - The word to pluralize (or singularize when count is 1)
|
|
174
|
+
* @param count - The count used to choose singular vs plural
|
|
175
|
+
* @param options - Options object or boolean: use `inclusive: true` (or `true`) to prefix with the number (e.g. "3 ducks")
|
|
176
|
+
* @returns The correctly inflected word, optionally prefixed with the count
|
|
177
|
+
*/
|
|
178
|
+
export declare function pluralize(word: string, count: number, options?: PluralizeOptions | boolean): string;
|
|
179
|
+
/** Options for toInMemoryBase64(). */
|
|
180
|
+
export interface EncodingOptions {
|
|
181
|
+
/** Maximum size of the resulting buffer in bytes. Default 1GB. */
|
|
182
|
+
maxSize?: number;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Reads a file and returns its contents as a base64-encoded buffer.
|
|
186
|
+
*
|
|
187
|
+
* @param srcPath - Full path to the file to encode
|
|
188
|
+
* @param opts - Encoding options (e.g. maxSize to cap buffer size)
|
|
189
|
+
* @returns Buffer containing the base64-encoded file content
|
|
190
|
+
* @throws {Error} If the file does not exist, is a directory, cannot be read, or exceeds maxSize
|
|
191
|
+
*/
|
|
192
|
+
export declare function toInMemoryBase64(srcPath: string, opts?: EncodingOptions): Promise<Buffer>;
|
|
193
|
+
/** Options for getLockFileGuard(). */
|
|
194
|
+
export interface LockFileOptions {
|
|
195
|
+
/** Max time in seconds to wait for the lock. Default 120. */
|
|
196
|
+
timeout?: number;
|
|
197
|
+
/** If true, attempt to unlock and retry once if the first acquisition times out (e.g. stale lock). */
|
|
198
|
+
tryRecovery?: boolean;
|
|
199
|
+
}
|
|
200
|
+
/** Guard function that runs the given behavior under the lock. */
|
|
201
|
+
type LockFileGuardFn<T> = (behavior: () => Promise<T> | T) => Promise<T>;
|
|
202
|
+
/** Return type of getLockFileGuard: guard function with a .check() method. */
|
|
203
|
+
type LockFileGuard<T> = LockFileGuardFn<T> & {
|
|
204
|
+
check: () => Promise<boolean>;
|
|
205
|
+
};
|
|
216
206
|
/**
|
|
217
|
-
*
|
|
218
|
-
*
|
|
219
|
-
*
|
|
207
|
+
* Creates a guard that serializes access to a critical section using a lock file.
|
|
208
|
+
* The returned function acquires the lock, runs the given behavior, then releases the lock.
|
|
209
|
+
* Also exposes `.check()` to test whether the lock is currently held.
|
|
220
210
|
*
|
|
221
|
-
* @
|
|
222
|
-
* @param
|
|
223
|
-
* @
|
|
224
|
-
* @returns async function that takes another async function defining the locked
|
|
225
|
-
* behavior
|
|
211
|
+
* @param lockFile - Full path to the lock file
|
|
212
|
+
* @param opts - Options (see {@link LockFileOptions})
|
|
213
|
+
* @returns Async function that accepts a callback to run under the lock, plus a `.check()` method
|
|
226
214
|
*/
|
|
227
|
-
export function getLockFileGuard<T>(lockFile: string, opts?: LockFileOptions):
|
|
228
|
-
(behavior: (...args: any[]) => T): Promise<T>;
|
|
229
|
-
check(): Promise<boolean>;
|
|
230
|
-
};
|
|
231
|
-
import B from 'bluebird';
|
|
232
|
-
export { uuidV1, uuidV3, uuidV4, uuidV5, shellParse };
|
|
215
|
+
export declare function getLockFileGuard<T>(lockFile: string, opts?: LockFileOptions): LockFileGuard<T>;
|
|
233
216
|
//# sourceMappingURL=util.d.ts.map
|
package/build/lib/util.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../lib/util.
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../lib/util.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,UAAU,CAAC;AASzB,OAAO,EAAsB,KAAK,IAAI,UAAU,EAAC,MAAM,aAAa,CAAC;AACrE,OAAO,EAAC,UAAU,EAAC,CAAC;AAGpB,OAAO,EAAC,EAAE,IAAI,MAAM,EAAE,EAAE,IAAI,MAAM,EAAE,EAAE,IAAI,MAAM,EAAE,EAAE,IAAI,MAAM,EAAC,MAAM,MAAM,CAAC;AAE5E,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,eAAe,CAAC;AAE3C,oEAAoE;AACpE,eAAO,MAAM,0BAA0B,wCAAwC,CAAC;AAEhF,4CAA4C;AAC5C,eAAO,MAAM,GAAG,OAAO,CAAC;AACxB,mDAAmD;AACnD,eAAO,MAAM,GAAG,QAAa,CAAC;AAC9B,0DAA0D;AAC1D,eAAO,MAAM,GAAG,QAAa,CAAC;AAE9B,oCAAoC;AACpC,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,EAAE,GAAG,KAAK,GAAG,CAAC,CAAC;AAEjF;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,cAAc,CAE9D;AA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