@j-o-r/sh 1.1.17 → 1.1.18

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
@@ -90,8 +90,13 @@ const parseDuration = (d) => {
90
90
  }
91
91
  throw new Error(`Unknown duration: "${d}".`);
92
92
  }
93
-
94
- /** @type {Shell & { (pieces: TemplateStringsArray, ...args: *): SHDispatch }} */
93
+ /**
94
+ * A template-tag that returns an SHDispatch.
95
+ * @typedef {(pieces: TemplateStringsArray, ...args: unknown[]) => SHDispatch} SHTag
96
+ */
97
+ /**
98
+ * @type {Shell & SHTag}
99
+ */
95
100
  const SH = new Proxy(function(pieces, ...args) {
96
101
  if (pieces.some((p) => p == undefined)) {
97
102
  throw new Error(`Malformed command ${pieces}`);
@@ -140,10 +145,12 @@ const within = async (callback) => {
140
145
 
141
146
  /**
142
147
  * This function reads the standard input (stdin) from the current process.
148
+ * @returns {Promise<string>}
143
149
  * @example
144
150
  * const content = await stdin();
145
151
  */
146
152
  const readIn = async () => {
153
+ if (process.stdin.isTTY) return ''; // nothing was piped
147
154
  let buf = '';
148
155
  process.stdin.setEncoding('utf8');
149
156
  for await (const chunk of process.stdin) {
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.17",
5
+ "version": "1.1.18",
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",
@@ -13,7 +13,7 @@
13
13
  "test": "npm run test:sh",
14
14
  "test:sh": "scenarios/sh.js",
15
15
  "publish": "npm run release && npm publish --access public",
16
- "release": "npm pack --pack-destination=release",
16
+ "release": "npm run types && npm pack --pack-destination=release",
17
17
  "types": "rm types/* && tsc -p tsc.json"
18
18
  },
19
19
  "repository": {
package/types/SH.d.ts CHANGED
@@ -7,10 +7,18 @@ export type ResolveCallback = Function;
7
7
  * Creates a new SHDispatch object that represents a command to be executed.
8
8
  */
9
9
  export type Shell = Function;
10
- /** @type {Shell & { (pieces: TemplateStringsArray, ...args: *): SHDispatch }} */
11
- export const SH: Shell & {
12
- (pieces: TemplateStringsArray, ...args: any): SHDispatch;
13
- };
10
+ /**
11
+ * A template-tag that returns an SHDispatch.
12
+ */
13
+ export type SHTag = (pieces: TemplateStringsArray, ...args: unknown[]) => SHDispatch;
14
+ /**
15
+ * A template-tag that returns an SHDispatch.
16
+ * @typedef {(pieces: TemplateStringsArray, ...args: unknown[]) => SHDispatch} SHTag
17
+ */
18
+ /**
19
+ * @type {Shell & SHTag}
20
+ */
21
+ export const SH: Shell & SHTag;
14
22
  /**
15
23
  * Change working directory
16
24
  * @param {string} dir
@@ -47,6 +55,7 @@ export function sleep(duration: string | number): Promise<any>;
47
55
  export function retry(count: number, a: string | number | typeof expBackoff | Function, b?: Function): Promise<any>;
48
56
  /**
49
57
  * This function reads the standard input (stdin) from the current process.
58
+ * @returns {Promise<string>}
50
59
  * @example
51
60
  * const content = await stdin();
52
61
  */