command-join

Escape and join command-line arguments, cross-platform.

MIT 8 个版本
安装
npm install command-join
yarn add command-join
pnpm add command-join
bun add command-join
README

command-join

Escape command-line arguments, cross-platform.

npm Build Status devDependency Status node

If you like this package, be sure to star its repo, and please consider donating.

Usage

import { commandJoin } from "command-join"

commandJoin(arg: string | string[]): string

Escapes each command-line argument and joins them into a string that can then be executed, e.g. via child_process.exec.

If a string is passed, an array containing the string will instead be processed.

Example

const command = commandJoin(['a', "b\\", "'c"])
command
// output on Windows: a "b\\" 'c
// output on Linux: a 'b\' \'c

See the tests for more convoluted examples.

Migrating

Migrating to v3:

- const commandJoin = require("command-join")
+ const { commandJoin } = require("command-join")
版本列表
3.0.0 2019-05-23
2.0.1 2019-05-23
2.0.0 2017-02-08
1.1.1 2016-09-28
1.1.0 2016-09-28
1.0.1 2015-12-06
1.0.0-2 2015-12-05
1.0.0 2015-12-06