Skip to content

Commit

Permalink
docs: add setup guide
Browse files Browse the repository at this point in the history
  • Loading branch information
antongolub committed May 9, 2024
1 parent f9145b2 commit 9bd9e75
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .vitepress/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ export default defineConfig({
text: 'Docs',
items: [
{text: 'Getting Started', link: '/getting-started'},
{text: 'Setup', link: '/setup'},
{text: 'Process Promise', link: '/process-promise'},
{text: 'API Reference', link: '/api'},
{text: 'Configuration', link: '/configuration'},
{text: 'CLI Usage', link: '/cli'},
{text: 'Package', link: '/package'},
{text: 'Migration from v7', link: '/migration-from-v7'},
],
},
Expand Down
51 changes: 47 additions & 4 deletions package.md → setup.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,49 @@
# Package
# Setup

## Hybrid
## Requirements
* JavaScript Runtime:
* Node.js 12.20.0 or later
* Bun 1.0.0 or later
* Some kind of bash or PowerShell

## Install

::: code-group

```bash [node]
npm install zx
```

```bash [bun]
bun install zx
```

```bash [deno]
deno install -A npm:zx
```

```bash [brew]
brew install zx
```

:::

## Bash

zx mostly relies on bash, so make sure it's available in your environment. If you're on Windows, consider using [Windows Subsystem for Linux](https://docs.microsoft.com/en-us/windows/wsl/install) or [Git Bash](https://git-scm.com/downloads).
By default, zx uses bash, but you can switch to PowerShell by invoking `usePowerShell()` or `usePwsh()`.

```js
import { useBash, usePowerShell, usePwsh } from 'zx'

usePowerShell() // Uses PowerShell.exe
usePwsh() // Looks for pwsh binary (PowerShell v7+)
useBash() // Switches back to bash
```

## Package

### Hybrid
zx is distributed as a [hybrid package](https://2ality.com/2019/10/hybrid-npm-packages.html): it provides both CJS an ESM entry points.

```js
Expand All @@ -20,15 +63,15 @@ const opts: Options = {
}
```

## Bundled
### Bundled

We use [esbuild](https://dev.to/antongolub/how-and-why-do-we-bundle-zx-1ca6) to produce a static build that allows us to solve several issues at once:
* Reduce the pkg size and install time.
* Make npx (yarn dlx / bunx) invocations reproducible.
* Provide support for wide range of Node.js versions: from 12 to 22.
* Make auditing easier: complete code in one place.

## Composite
### Composite

zx exports several entry points adapted for different use cases:
* `zx` – the main entry point, provides all the features.
Expand Down

0 comments on commit 9bd9e75

Please sign in to comment.