Skip to content

Latest commit

 

History

History
31 lines (22 loc) · 893 Bytes

File metadata and controls

31 lines (22 loc) · 893 Bytes
description Modern alternatives to the ez-spawn package for spawning child processes

Replacements for @jsdevtools/ez-spawn

tinyexec

ez-spawn accepts shell-like command strings, which tinyexec does not.

For example:

import ezSpawn from '@jsdevtools/ez-spawn' // [!code --]
import { x } from 'tinyexec' // [!code ++]

await ezSpawn.async('ls -l') // [!code --]
await x('ls', ['-l']) // [!code ++]

Alternatively, you can use args-tokenizer to convert a shell string to a command and arguments:

import ezSpawn from '@jsdevtools/ez-spawn' // [!code --]
import { tokenizeArgs } from 'args-tokenizer' // [!code ++]
import { x } from 'tinyexec' // [!code ++]

const [command, ...args] = tokenizeArgs('ls -l') // [!code ++]
await ezSpawn.async('ls -l') // [!code --]
await x(command, args) // [!code ++]