@j-o-r/sh 1.1.4 → 1.1.5
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/lib/SH.js +27 -20
- package/package.json +1 -1
- package/types/SH.d.ts +30 -21
package/lib/SH.js
CHANGED
|
@@ -31,27 +31,34 @@ import SHDispatch from './SHDispatch.js';
|
|
|
31
31
|
import Test from './Test.js'
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
* @typedef {Object.<string, string>} ArgsObject
|
|
35
|
+
* @property {string} [key: string] - Any string key maps to an object
|
|
36
|
+
* @property {string[]} _ - Array of strings, unnamed parameters
|
|
37
|
+
* @description Parsed parameters result.
|
|
38
|
+
*/
|
|
39
|
+
|
|
37
40
|
/**
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
* @typedef {Function} RejectCallback
|
|
42
|
+
* @param {Error} error - The error object passed to the callback.
|
|
43
|
+
*/
|
|
41
44
|
/**
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
45
|
+
* @typedef {Function} ResolveCallback
|
|
46
|
+
* @param {any} [param] - Optional callback any value
|
|
47
|
+
*/
|
|
48
|
+
/**
|
|
49
|
+
* Creates a new SHDispatch object that represents a command to be executed.
|
|
50
|
+
*
|
|
51
|
+
* @typedef {Function} Shell
|
|
52
|
+
* @property {function(Array, ...*): ProcessPromise} execute - The function to execute the command.
|
|
53
|
+
*
|
|
54
|
+
* @param {Array} pieces - An array of string literals from a template literal.
|
|
55
|
+
* @param {...*} args - The values to be interpolated into the string literals.
|
|
56
|
+
* @returns {SHDispatch} Trigger for the command.
|
|
57
|
+
* @throws {Error} Throws an error if any of the string literals in `pieces` is undefined.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* const command = await SH`echo 'Hello, world!'`.run();
|
|
61
|
+
*/
|
|
55
62
|
|
|
56
63
|
/**
|
|
57
64
|
* Determine a javascript type
|
|
@@ -259,7 +266,7 @@ function* expBackoff(max = '60s', rand = '100ms') {
|
|
|
259
266
|
* All unrecognized arguments are collected in an array under the `_` property.
|
|
260
267
|
*
|
|
261
268
|
* @param {string[]} args - An array of command-line arguments.
|
|
262
|
-
* @returns {
|
|
269
|
+
* @returns {ArgsObject} An object where:
|
|
263
270
|
* - Each key corresponds to an argument that starts with `--`,
|
|
264
271
|
* - The value is either the next argument or `true` if no value is provided,
|
|
265
272
|
* - The `_` property contains an array of unbound arguments.
|
package/package.json
CHANGED
package/types/SH.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
export type ArgsObject = {
|
|
2
|
+
[x: string]: ApiMethod;
|
|
3
|
+
};
|
|
1
4
|
export type RejectCallback = Function;
|
|
2
5
|
export type ResolveCallback = Function;
|
|
3
6
|
/**
|
|
@@ -83,34 +86,40 @@ export function expBackoff(max?: string | undefined, rand?: string | undefined):
|
|
|
83
86
|
* All unrecognized arguments are collected in an array under the `_` property.
|
|
84
87
|
*
|
|
85
88
|
* @param {string[]} args - An array of command-line arguments.
|
|
86
|
-
* @returns {
|
|
89
|
+
* @returns {ArgsObject} An object where:
|
|
87
90
|
* - Each key corresponds to an argument that starts with `--`,
|
|
88
91
|
* - The value is either the next argument or `true` if no value is provided,
|
|
89
92
|
* - The `_` property contains an array of unbound arguments.
|
|
90
93
|
*/
|
|
91
|
-
export function parseArgs(args: string[]):
|
|
94
|
+
export function parseArgs(args: string[]): ArgsObject;
|
|
92
95
|
/**
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
+
* @typedef {Object.<string, ApiMethod>} ArgsObject
|
|
97
|
+
* @property {string} [key: string] - Any string key maps to an object
|
|
98
|
+
* @property {string[]} _ - Array of strings, unnamed parameters
|
|
99
|
+
* @description Parse parameters result.
|
|
100
|
+
*/
|
|
96
101
|
/**
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
102
|
+
* @typedef {Function} RejectCallback
|
|
103
|
+
* @param {Error} error - The error object passed to the callback.
|
|
104
|
+
*/
|
|
100
105
|
/**
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
106
|
+
* @typedef {Function} ResolveCallback
|
|
107
|
+
* @param {any} [param] - Optional callback any value
|
|
108
|
+
*/
|
|
109
|
+
/**
|
|
110
|
+
* Creates a new SHDispatch object that represents a command to be executed.
|
|
111
|
+
*
|
|
112
|
+
* @typedef {Function} Shell
|
|
113
|
+
* @property {function(Array, ...*): ProcessPromise} execute - The function to execute the command.
|
|
114
|
+
*
|
|
115
|
+
* @param {Array} pieces - An array of string literals from a template literal.
|
|
116
|
+
* @param {...*} args - The values to be interpolated into the string literals.
|
|
117
|
+
* @returns {SHDispatch} Trigger for the command.
|
|
118
|
+
* @throws {Error} Throws an error if any of the string literals in `pieces` is undefined.
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* const command = await SH`echo 'Hello, world!'`.run();
|
|
122
|
+
*/
|
|
114
123
|
/**
|
|
115
124
|
* Determine a javascript type
|
|
116
125
|
*
|