Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
antonmedv committed Sep 5, 2023
1 parent 3f345fe commit b8fc217
Showing 1 changed file with 6 additions and 17 deletions.
23 changes: 6 additions & 17 deletions cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Zx provides a CLI for running scripts. It is installed with the package and can
zx script.mjs
```

## Scripts without extensions
## No extensions

If script does not have a file extension (like `.git/hooks/pre-commit`), zx
assumes that it is
Expand All @@ -17,7 +17,7 @@ module.
zx docs/markdown.md
```

## Executing remote scripts
## Remote scripts

If the argument to the `zx` executable starts with `https://`, the file will be
downloaded and executed.
Expand All @@ -26,7 +26,7 @@ downloaded and executed.
zx https://medv.io/game-of-life.js
```

## Executing scripts from stdin
## Scripts from stdin

The `zx` supports executing scripts from stdin.

Expand All @@ -36,15 +36,15 @@ await $`pwd`
EOF
```

## Executing scripts via --eval
## --eval

Evaluate the following argument as a script.

```bash
cat package.json | zx --eval 'const v = JSON.parse(await stdin()).version; echo(v)'
```

## Installing dependencies via --install
## --install

```js
// script.mjs:
Expand All @@ -67,18 +67,7 @@ the import.
import sh from 'tinysh' // @^1
```

## Executing commands on remote hosts

The `zx` uses [webpod](https://github.com/webpod/webpod) to execute commands on
remote hosts.

```js
import {ssh} from 'zx'

await ssh('user@host')`echo Hello, world!`
```

## `__filename` and `__dirname`
## __filename & __dirname

In [ESM](https://nodejs.org/api/esm.html) modules, Node.js does not provide
`__filename` and `__dirname` globals. As such globals are really handy in scripts,
Expand Down

0 comments on commit b8fc217

Please sign in to comment.