@j-o-r/sh 1.1.3 → 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 CHANGED
@@ -31,27 +31,34 @@ import SHDispatch from './SHDispatch.js';
31
31
  import Test from './Test.js'
32
32
 
33
33
  /**
34
- * @typedef {Function} RejectCallback
35
- * @param {Error} error - The error object passed to the callback.
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
- * @typedef {Function} ResolveCallback
39
- * @param {any} [param] - Optional callback any value
40
- */
41
+ * @typedef {Function} RejectCallback
42
+ * @param {Error} error - The error object passed to the callback.
43
+ */
41
44
  /**
42
- * Creates a new SHDispatch object that represents a command to be executed.
43
- *
44
- * @typedef {Function} Shell
45
- * @property {function(Array, ...*): ProcessPromise} execute - The function to execute the command.
46
- *
47
- * @param {Array} pieces - An array of string literals from a template literal.
48
- * @param {...*} args - The values to be interpolated into the string literals.
49
- * @returns {SHDispatch} Trigger for the command.
50
- * @throws {Error} Throws an error if any of the string literals in `pieces` is undefined.
51
- *
52
- * @example
53
- * const command = await SH`echo 'Hello, world!'`.run();
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 {object} An object where:
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/lib/Test.js CHANGED
@@ -103,6 +103,7 @@ class Test {
103
103
  * @param {string} description
104
104
  * @param {Function|AsyncFunction} callback - sync / async function
105
105
  * @throws Error when conditions are not met
106
+ * @returns {Test}
106
107
  */
107
108
  add(description, callback) {
108
109
  if (jsType(description) !== 'String') {
@@ -112,6 +113,7 @@ class Test {
112
113
  throw new Error(`'callback' should be a (async) Function`)
113
114
  }
114
115
  this.#tests.push({ description, callback });
116
+ return this;
115
117
  }
116
118
  /**
117
119
  * Execute tests
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@j-o-r/sh",
3
3
  "author": "Jorrit Duin <j-o-r@duin.work>",
4
4
  "type": "module",
5
- "version": "1.1.3",
5
+ "version": "1.1.5",
6
6
  "description": "Execute shell commands on Linux-based systems from javascript",
7
7
  "main": "lib/SH.js",
8
8
  "types": "types/SH.d.ts",
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 {object} An object where:
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[]): object;
94
+ export function parseArgs(args: string[]): ArgsObject;
92
95
  /**
93
- * @typedef {Function} RejectCallback
94
- * @param {Error} error - The error object passed to the callback.
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
- * @typedef {Function} ResolveCallback
98
- * @param {any} [param] - Optional callback any value
99
- */
102
+ * @typedef {Function} RejectCallback
103
+ * @param {Error} error - The error object passed to the callback.
104
+ */
100
105
  /**
101
- * Creates a new SHDispatch object that represents a command to be executed.
102
- *
103
- * @typedef {Function} Shell
104
- * @property {function(Array, ...*): ProcessPromise} execute - The function to execute the command.
105
- *
106
- * @param {Array} pieces - An array of string literals from a template literal.
107
- * @param {...*} args - The values to be interpolated into the string literals.
108
- * @returns {SHDispatch} Trigger for the command.
109
- * @throws {Error} Throws an error if any of the string literals in `pieces` is undefined.
110
- *
111
- * @example
112
- * const command = await SH`echo 'Hello, world!'`.run();
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
  *
package/types/Test.d.ts CHANGED
@@ -50,8 +50,9 @@ declare class Test {
50
50
  * @param {string} description
51
51
  * @param {Function|AsyncFunction} callback - sync / async function
52
52
  * @throws Error when conditions are not met
53
+ * @returns {Test}
53
54
  */
54
- add(description: string, callback: Function | AsyncFunction): void;
55
+ add(description: string, callback: Function | AsyncFunction): Test;
55
56
  /**
56
57
  * Execute tests
57
58
  * @param {number[]} [execute] - limit the execution tests