UNPKG

1.19 kBMarkdownView Raw
1# `@yarnpkg/shell`
2
3A JavaScript implementation of a bash-like shell (we use it in Yarn 2 to provide cross-platform scripting). This package exposes an API that abstracts both the parser and the interpreter; should you only need the parser you can check out `@yarnpkg/parsers`, but you probably won't need it.
4
5## Usage
6
7```ts
8import {execute} from '@yarnpkg/shell';
9
10process.exitCode = await execute(`ls "$0" | wc -l`, [process.cwd()]);
11```
12
13## Features
14
15- Typechecked
16- Portable across systems
17- Supports custom JS builtins
18- Supports pipes
19- Supports glob patterns (**only** for files that exist on the filesystem: `ls *.txt`)
20- Supports logical operators
21- Supports subshells
22- Supports variables
23- Supports string manipulators
24- Supports argc/argv
25- Supports background jobs with color-coded output
26- Supports the most classic builtins
27- Doesn't necessarily need to access the fs
28
29## Help Wanted
30
31- Full glob support (`mv build/{index.js,index.build.js}`, `echo {foo,bar}`, `FOO=a,b echo {$FOO,x}`)
32- More string manipulators
33
34## Non-Goals
35
36- Perfect POSIX compliance (basic scripting is enough for now)
37- Multiline scripts (we mostly target one-liners)
38- Control structures (same reason)