Skip to content

Commit 6038bb9

Browse files
Merge branch 'main' into link-to-link-to-shell
2 parents d579020 + bccf14b commit 6038bb9

3 files changed

Lines changed: 21 additions & 12 deletions

File tree

src/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ export class Shescape {
118118
* Take an array of values, the arguments, and escape any dangerous characters
119119
* in every argument.
120120
*
121-
* Non-string inputs will be converted to strings using a `toString()` method.
121+
* Non-array inputs are rejected. Non-string entries will be converted to
122+
* strings using a `toString()` method.
122123
*
123124
* @param {string[]} args The arguments to escape.
124125
* @returns {string[]} The escaped arguments.
@@ -152,7 +153,8 @@ export class Shescape {
152153
* Take an array of values, the arguments, put shell-specific quotes around
153154
* every argument and escape any dangerous characters in every argument.
154155
*
155-
* Non-string inputs will be converted to strings using a `toString()` method.
156+
* Non-array inputs are rejected. Non-string entries will be converted to
157+
* strings using a `toString()` method.
156158
*
157159
* @param {string[]} args The arguments to quote and escape.
158160
* @returns {string[]} The quoted and escaped arguments.

src/stateless.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ export function escape(arg, options) {
3636
* Take an array of values, the arguments, and escape any dangerous characters
3737
* in every argument.
3838
*
39-
* Non-array inputs will be converted to one-value arrays and non-string values
40-
* will be converted to strings using a `toString()` method.
39+
* Non-array inputs are rejected. Non-string entries will be converted to
40+
* strings using a `toString()` method.
4141
*
4242
* @example
4343
* import { spawn } from "node:child_process";
@@ -51,6 +51,7 @@ export function escape(arg, options) {
5151
* @param {boolean} [options.flagProtection=true] Is flag protection enabled.
5252
* @param {boolean | string} [options.shell=true] The shell to escape for.
5353
* @returns {string[]} The escaped arguments.
54+
* @throws {TypeError} The arguments are not an array.
5455
* @throws {TypeError} One of the arguments is not stringable.
5556
* @throws {Error} The shell is not supported or could not be found.
5657
* @since 2.1.0
@@ -93,8 +94,8 @@ export function quote(arg, options) {
9394
* Take an array of values, the arguments, put shell-specific quotes around
9495
* every argument and escape any dangerous characters in every argument.
9596
*
96-
* Non-array inputs will be converted to one-value arrays and non-string
97-
* values will be converted to strings using a `toString()` method.
97+
* Non-array inputs are rejected. Non-string entries will be converted to
98+
* strings using a `toString()` method.
9899
*
99100
* @example
100101
* import { spawn } from "node:child_process";
@@ -109,6 +110,7 @@ export function quote(arg, options) {
109110
* @param {boolean} [options.flagProtection=true] Is flag protection enabled.
110111
* @param {boolean | string} [options.shell=true] The shell to escape for.
111112
* @returns {string[]} The quoted and escaped arguments.
113+
* @throws {TypeError} The arguments are not an array.
112114
* @throws {TypeError} One of the arguments is not stringable.
113115
* @throws {Error} The shell is not supported or could not be found.
114116
* @throws {Error} Quoting is not supported with `shell: false`.

test/e2e/_common.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,25 +46,30 @@ export function getTestFn(shell) {
4646
* @returns {(boolean | string)[]} A list of `shell` option values.
4747
*/
4848
export function getTestShells() {
49+
const temp = path.resolve(import.meta.dirname, "..", "..", ".temp");
4950
const systemShells = constants.isWindows
5051
? constants.shellsWindows
5152
: constants.shellsUnix;
5253

53-
const temp = path.resolve(import.meta.dirname, "..", "..", ".temp");
54+
const shells = [false, ...systemShells];
5455

55-
const busyboxIndex = systemShells.indexOf(constants.binBusyBox);
56+
const busyboxIndex = shells.indexOf(constants.binBusyBox);
5657
if (busyboxIndex !== -1) {
5758
if (constants.isMacOS) {
58-
systemShells.splice(busyboxIndex, 1);
59+
shells.splice(busyboxIndex, 1);
5960
} else {
60-
systemShells[busyboxIndex] = path.resolve(temp, "busybox", "sh");
61+
shells[busyboxIndex] = path.resolve(temp, "busybox", "sh");
6162
}
6263
}
6364

6465
if (constants.isLinux) {
6566
const doubleLinkedShell = path.resolve(temp, "double-link", "link-to-link");
66-
systemShells.push(doubleLinkedShell);
67+
shells.push(doubleLinkedShell);
68+
}
69+
70+
if (!constants.isMacOS) {
71+
shells.push(true);
6772
}
6873

69-
return [false, ...systemShells];
74+
return shells;
7075
}

0 commit comments

Comments
 (0)