UNPKG

1.14 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 "$1" | 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 the most classic builtins
26- Doesn't necessarily need to access the fs
27
28## Help Wanted
29
30- Full glob support (`mv build/{index.js,index.build.js}`, `echo {foo,bar}`, `FOO=a,b echo {$FOO,x}`)
31- More string manipulators
32
33## Non-Goals
34
35- Perfect POSIX compliance (basic scripting is enough for now)
36- Multiline scripts (we mostly target one-liners)
37- Control structures (same reason)