Commit 7891813
Changed files (5)
build/util.cjs
@@ -110,9 +110,7 @@ var proxyOverride = (origin, ...fallbacks) => new Proxy(origin, {
return (_b = (_a = fallbacks.find((f) => key in f)) == null ? void 0 : _a[key]) != null ? _b : Reflect.get(target, key);
}
});
-var toCamelCase = (str) => str.toLowerCase().replace(/([a-z])[_-]+([a-z])/g, (_, p1, p2) => {
- return p1 + p2.toUpperCase();
-});
+var toCamelCase = (str) => str.toLowerCase().replace(/([a-z])[_-]+([a-z])/g, (_, p1, p2) => p1 + p2.toUpperCase());
var parseBool = (v) => v === "true" || v !== "false" && v;
var getLines = (chunk, next) => {
const lines = ((next.pop() || "") + bufToString(chunk)).split(/\r?\n/);
docs/.vitepress/config.mts
@@ -78,34 +78,11 @@ export default defineConfig({
{ text: 'Quotes', link: '/quotes' },
{ text: 'Shell', link: '/shell' },
{ text: 'TypeScript', link: '/typescript' },
- { text: 'Markdown Scripts', link: '/markdown-scripts' },
+ { text: 'Markdown Scripts', link: '/markdown' },
{ text: 'Known Issues', link: '/known-issues' },
],
},
],
-
- '/v7/': [
- {
- text: 'Docs (v7)',
- items: [
- { text: 'Getting Started', link: '/v7/getting-started' },
- { text: 'Process Promise', link: '/v7/process-promise' },
- { text: 'API Reference', link: '/v7/api' },
- { text: 'Configuration', link: '/v7/configuration' },
- { text: 'CLI Usage', link: '/v7/cli' },
- ],
- },
- {
- text: 'FAQ',
- link: '/v7/faq',
- items: [
- { text: 'Quotes', link: '/v7/quotes' },
- { text: 'TypeScript', link: '/v7/typescript' },
- { text: 'Markdown Scripts', link: '/v7/markdown-scripts' },
- { text: 'Known Issues', link: '/v7/known-issues' },
- ],
- },
- ],
},
socialLinks: [{ icon: 'github', link: 'https://github.com/google/zx' }],
docs/markdown-scripts.md
@@ -1,46 +0,0 @@
-# Markdown Scripts
-
-It's possible to write scripts using markdown. Only code blocks will be executed
-by zx.
-
-> You can run this markdown file:
->
-> ```
-> zx docs/markdown.md
-> ```
-
-```js
-await $`whoami`
-await $`echo ${__dirname}`
-```
-
-```ts
-await $`pwd`
-```
-
-The `__filename` will be pointed to **markdown.md**:
-
-```js
-console.log(chalk.yellowBright(__filename))
-```
-
-We can use imports here as well:
-
-```js
-await import('chalk')
-```
-
-A bash code (with `bash` or `sh` language tags) also will be executed:
-
-```bash
-VAR=$(date)
-echo "$VAR" | wc -c
-```
-
-Other code blocks are ignored:
-
-```css
-body .hero {
- margin: 42px;
-}
-```
docs/markdown.md
@@ -1,7 +1,7 @@
-# Markdown
+# Markdown Scripts
-Imagine a script with code blocks, comments, schemas, illustrations, etc. Markdown is right for this purpose.
-Combine `ts`, `js`, `bash` sections to produce a single script. For example:
+Imagine a script with code blocks, formatted comments, schemas, illustrations, etc. [Markdown](https://en.wikipedia.org/wiki/Markdown) is right for this purpose.
+Combine `ts`, `js`, `bash` sections to produce a single zx scenario. For example:
````text
# Some script
@@ -40,3 +40,32 @@ The rest is simple: just run via `zx` command:
```bash
zx script.md
```
+
+## Hints
+You can use imports here as well:
+
+```js
+await import('chalk')
+```
+
+`js`, `javascript`, `ts`, `typescript`, `sh`, `shell`, `bash` code blocks will be executed by zx.
+
+```bash
+VAR=$(date)
+echo "$VAR" | wc -c
+```
+
+Other kinds are ignored:
+
+```css
+body .hero {
+ margin: 42px;
+}
+```
+
+The `__filename` will be pointed to **markdown.md**:
+
+```js
+console.log(chalk.yellowBright(__filename))
+```
+
src/util.ts
@@ -163,9 +163,9 @@ export const proxyOverride = <T extends object>(
}) as T
export const toCamelCase = (str: string) =>
- str.toLowerCase().replace(/([a-z])[_-]+([a-z])/g, (_, p1, p2) => {
- return p1 + p2.toUpperCase()
- })
+ str
+ .toLowerCase()
+ .replace(/([a-z])[_-]+([a-z])/g, (_, p1, p2) => p1 + p2.toUpperCase())
export const parseBool = (v: string): boolean | string =>
v === 'true' || (v !== 'false' && v)