-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquote.ts
More file actions
24 lines (22 loc) · 822 Bytes
/
quote.ts
File metadata and controls
24 lines (22 loc) · 822 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/**
* @file Escape an argv array into a single shell-safe command string. Wraps the
* vendored `shell-quote`. Use when building a command line for display, a log
* line, or a copy-pasteable reproduction — the inverse of `parseShell`. The
* output targets POSIX `sh` quoting, not `cmd.exe`; spawn callers should pass
* an argv array to `child_process.spawn` directly rather than quoting into a
* shell string.
*/
import { quote as shellQuote } from '../external/shell-quote'
/**
* Escape an array of arguments into a shell-safe command string.
*
* @example
* quote(['git', 'commit', '-m', 'hello world'])
* // → "git commit -m 'hello world'"
*
* quote(['echo', '$HOME'])
* // → "echo \\$HOME"
*/
export function quote(argv: readonly string[]): string {
return shellQuote(argv)
}