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 bbe6044 commit 3f345fe
Show file tree
Hide file tree
Showing 10 changed files with 93 additions and 31 deletions.
14 changes: 14 additions & 0 deletions .vitepress/theme/MyLayout.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<script setup>
import DefaultTheme from 'vitepress/theme'
import MyOxygen from './MyOxygen.vue'
const { Layout } = DefaultTheme
</script>

<template>
<Layout>
<template #aside-ads-after>
<MyOxygen/>
</template>
</Layout>
</template>
42 changes: 42 additions & 0 deletions .vitepress/theme/MyOxygen.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<template>
<div class="Oxygen">
<a href="https://webpod.dev/?from=zx-site">
<!--<img src="https://webpod.dev/img/banner.png" alt="Webpod - deploy JavaScript apps">-->
<img src="https://webpod.dev/img/logo.svg" alt="Webpod - deploy JavaScript apps">
<p>Webpod – deploy JavaScript apps to own cloud or private server</p>
</a>
</div>
</template>

<style scoped>
.Oxygen {
display: flex;
justify-content: center;
align-items: center;
padding: 24px;
border-radius: 12px;
min-height: 256px;
text-align: center;
line-height: 18px;
font-size: 12px;
font-weight: 500;
background-color: var(--vp-carbon-ads-bg-color);
}
.Oxygen :deep(img) {
margin: 0 auto;
}
.Oxygen :deep(p) {
display: block;
margin: 0 auto;
color: var(--vp-carbon-ads-text-color);
transition: color 0.25s;
}
.Oxygen :deep(p:hover) {
color: var(--vp-carbon-ads-hover-text-color);
}
</style>
<script setup>
</script>
8 changes: 7 additions & 1 deletion .vitepress/theme/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import DefaultTheme from 'vitepress/theme'
import MyLayout from './MyLayout.vue'
import './custom.css'

export default DefaultTheme
export default {
...DefaultTheme,
// override the Layout with a wrapper component that
// injects the slots
Layout: MyLayout
}
22 changes: 11 additions & 11 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ A wrapper around the [node-fetch](https://www.npmjs.com/package/node-fetch)
package.

```js
let resp = await fetch('https://medv.io')
const resp = await fetch('https://medv.io')
```

## question()

A wrapper around the [readline](https://nodejs.org/api/readline.html) package.

```js
let bear = await question('What kind of bear is best? ')
const bear = await question('What kind of bear is best? ')
```

## sleep()
Expand All @@ -46,7 +46,7 @@ await sleep(1000)
A `console.log()` alternative which can take [ProcessOutput](#processoutput).

```js
let branch = await $`git branch --show-current`
const branch = await $`git branch --show-current`

echo`Current branch is ${branch}.`
// or
Expand All @@ -58,7 +58,7 @@ echo('Current branch is', branch)
Returns the stdin as a string.

```js
let content = JSON.parse(await stdin())
const content = JSON.parse(await stdin())
```

## within()
Expand All @@ -82,7 +82,7 @@ await $`pwd` // => /home/path
```js
await $`node --version` // => v20.2.0

let version = await within(async () => {
const version = await within(async () => {
$.prefix += 'export NVM_DIR=$HOME/.nvm; source $NVM_DIR/nvm.sh; nvm use 16;'

return $`node --version`
Expand All @@ -97,13 +97,13 @@ Retries a callback for a few times. Will return after the first
successful attempt, or will throw after specifies attempts count.

```js
let p = await retry(10, () => $`curl https://medv.io`)
const p = await retry(10, () => $`curl https://medv.io`)

// With a specified delay between attempts.
let p = await retry(20, '1s', () => $`curl https://medv.io`)
const p = await retry(20, '1s', () => $`curl https://medv.io`)

// With an exponential backoff.
let p = await retry(30, expBackoff(), () => $`curl https://medv.io`)
const p = await retry(30, expBackoff(), () => $`curl https://medv.io`)
```

## spinner()
Expand All @@ -122,15 +122,15 @@ await spinner('working...', () => $`sleep 99`)
The [globby](https://github.com/sindresorhus/globby) package.

```js
let packages = await glob(['package.json', 'packages/*/package.json'])
const packages = await glob(['package.json', 'packages/*/package.json'])
```

## which()

The [which](https://github.com/npm/node-which) package.

```js
let node = await which('node')
const node = await which('node')
```

## argv
Expand Down Expand Up @@ -172,7 +172,7 @@ console.log(chalk.blue('Hello world!'))
The [fs-extra](https://www.npmjs.com/package/fs-extra) package.

```js
let {version} = await fs.readJson('./package.json')
const {version} = await fs.readJson('./package.json')
```

## os
Expand Down
4 changes: 2 additions & 2 deletions cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ EOF
Evaluate the following argument as a script.

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

## Installing dependencies via --install
Expand Down Expand Up @@ -92,5 +92,5 @@ The `zx` provides `require()` function, so it can be used with imports in `.mjs`
files (when using `zx` executable).

```js
let {version} = require('./package.json')
const {version} = require('./package.json')
```
2 changes: 1 addition & 1 deletion faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ individually and concatenated via space.
Example:

```js
let files = [...]
const files = [...]
await $`tar cz ${files}`
```

Expand Down
10 changes: 5 additions & 5 deletions getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

await $`cat package.json | grep name`

let branch = await $`git branch --show-current`
const branch = await $`git branch --show-current`
await $`dep deploy --branch=${branch}`

await Promise.all([
Expand All @@ -16,7 +16,7 @@ await Promise.all([
$`sleep 3; echo 3`,
])

let name = 'foo bar'
const name = 'foo bar'
await $`mkdir /tmp/${name}`
```

Expand Down Expand Up @@ -75,7 +75,7 @@ and returns [`ProcessPromise`](process-promise.md).
Everything passed through `${...}` will be automatically escaped and quoted.

```js
let name = 'foo & bar'
const name = 'foo & bar'
await $`mkdir ${name}`
```

Expand All @@ -85,7 +85,7 @@ await $`mkdir ${name}`
You can pass an array of arguments if needed:

```js
let flags = [
const flags = [
'--oneline',
'--decorate',
'--color',
Expand Down Expand Up @@ -124,7 +124,7 @@ If `ProcessOutput` is used as an argument to some other `$` process,
**zx** will use stdout and trim the new line.

```js
let date = await $`date`
const date = await $`date`
await $`echo Current date is ${date}.`
```

Expand Down
4 changes: 2 additions & 2 deletions known-issues.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ process to exit itself. Or use something like [exit](https://www.npmjs.com/packa

Workaround is to write to a temp file:
```js
let tmp = await $`mktemp` // Creates a temp file.
let {stdout} = await $`cmd > ${tmp}; cat ${tmp}`
const tmp = await $`mktemp` // Creates a temp file.
const {stdout} = await $`cmd > ${tmp}; cat ${tmp}`
```

## Colors in subprocess
Expand Down
10 changes: 5 additions & 5 deletions process-promise.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
The `$` returns a `ProcessPromise` instance.

```js
let p = $`command`
const p = $`command`

await p
```
Expand All @@ -16,7 +16,7 @@ this getter will trigger execution of a subprocess with [`stdio('pipe')`](#stdio
Do not forget to end the stream.

```js
let p = $`while read; do echo $REPLY; done`
const p = $`while read; do echo $REPLY; done`
p.stdin.write('Hello, World!\n')
p.stdin.end()
```
Expand Down Expand Up @@ -65,7 +65,7 @@ await $`echo 1; sleep 1; echo 2; sleep 1; echo 3;`
The `pipe()` method can combine `$` processes. Same as `|` in bash:

```js
let greeting = await $`printf "hello"`
const greeting = await $`printf "hello"`
.pipe($`awk '{printf $1", world!"}'`)
.pipe($`tr '[a-z]' '[A-Z]'`)

Expand All @@ -87,7 +87,7 @@ Kills the process and all children.
By default, signal `SIGTERM` is sent. You can specify a signal via an argument.

```js
let p = $`sleep 999`
const p = $`sleep 999`
setTimeout(() => p.kill('SIGINT'), 100)
await p
```
Expand All @@ -99,7 +99,7 @@ Specifies a stdio for the process.
Default is `.stdio('inherit', 'pipe', 'pipe')`.

```js
let p = $`read`.stdio('pipe')
const p = $`read`.stdio('pipe')
```

## `nothrow()`
Expand Down
8 changes: 4 additions & 4 deletions quotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ When passing arguments to `${...}` there is no need to add quotes. **Quotes will
be added automatically if needed.**

```js
let name = 'foo & bar'
const name = 'foo & bar'
await $`mkdir ${name}`
```

Expand Down Expand Up @@ -37,7 +37,7 @@ will be quoted separately and concatenated via a space.
Do **not** add a `.join(' ')`.

```js
let flags = [
const flags = [
'--oneline',
'--decorate',
'--color',
Expand All @@ -63,13 +63,13 @@ In order for this to work the zx provides
For instead of this:

```js
let files = '~/dev/**/*.md' // wrong
const files = '~/dev/**/*.md' // wrong
await $`ls ${files}`
```

Use `glob` function and `os` package:

```js
let files = await glob(os.homedir() + '/dev/**/*.md')
const files = await glob(os.homedir() + '/dev/**/*.md')
await $`ls ${files}`
```

0 comments on commit 3f345fe

Please sign in to comment.