diff --git a/.vitepress/theme/MyLayout.vue b/.vitepress/theme/MyLayout.vue new file mode 100644 index 0000000000..1d171ca117 --- /dev/null +++ b/.vitepress/theme/MyLayout.vue @@ -0,0 +1,14 @@ + + + diff --git a/.vitepress/theme/MyOxygen.vue b/.vitepress/theme/MyOxygen.vue new file mode 100644 index 0000000000..2b4c1fcacc --- /dev/null +++ b/.vitepress/theme/MyOxygen.vue @@ -0,0 +1,42 @@ + + + + diff --git a/.vitepress/theme/index.js b/.vitepress/theme/index.js index 42fe9a9361..8aec99edc9 100644 --- a/.vitepress/theme/index.js +++ b/.vitepress/theme/index.js @@ -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 +} diff --git a/api.md b/api.md index 76e7c0b07d..e7a9609ae1 100644 --- a/api.md +++ b/api.md @@ -22,7 +22,7 @@ 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() @@ -30,7 +30,7 @@ let resp = await fetch('https://medv.io') 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() @@ -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 @@ -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() @@ -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` @@ -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() @@ -122,7 +122,7 @@ 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() @@ -130,7 +130,7 @@ let packages = await glob(['package.json', 'packages/*/package.json']) The [which](https://github.com/npm/node-which) package. ```js -let node = await which('node') +const node = await which('node') ``` ## argv @@ -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 diff --git a/cli.md b/cli.md index 78403dd874..4041475730 100644 --- a/cli.md +++ b/cli.md @@ -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 @@ -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') ``` diff --git a/faq.md b/faq.md index f582971811..bc217b64a6 100644 --- a/faq.md +++ b/faq.md @@ -16,7 +16,7 @@ individually and concatenated via space. Example: ```js -let files = [...] +const files = [...] await $`tar cz ${files}` ``` diff --git a/getting-started.md b/getting-started.md index 7049799320..a6749274c1 100644 --- a/getting-started.md +++ b/getting-started.md @@ -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([ @@ -16,7 +16,7 @@ await Promise.all([ $`sleep 3; echo 3`, ]) -let name = 'foo bar' +const name = 'foo bar' await $`mkdir /tmp/${name}` ``` @@ -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}` ``` @@ -85,7 +85,7 @@ await $`mkdir ${name}` You can pass an array of arguments if needed: ```js -let flags = [ +const flags = [ '--oneline', '--decorate', '--color', @@ -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}.` ``` diff --git a/known-issues.md b/known-issues.md index 193c6f78d4..7de7f2cfe1 100644 --- a/known-issues.md +++ b/known-issues.md @@ -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 diff --git a/process-promise.md b/process-promise.md index e5435783cf..d355511127 100644 --- a/process-promise.md +++ b/process-promise.md @@ -3,7 +3,7 @@ The `$` returns a `ProcessPromise` instance. ```js -let p = $`command` +const p = $`command` await p ``` @@ -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() ``` @@ -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]'`) @@ -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 ``` @@ -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()` diff --git a/quotes.md b/quotes.md index af78c75df0..84da9e1a39 100644 --- a/quotes.md +++ b/quotes.md @@ -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}` ``` @@ -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', @@ -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}` ```