

























zx 的语法简单,就是js,对于进行script 操作比较方便,以下是一个简单试用
方法比较多,可以是cli模式,也可以是npm包模式
# Some script
`ls` — is an unix command to get directory contents. Let's see how to use it in `zx`:
```js
// ts, js, cjs, mjs, etc
const {stdout} = await $`ls -l`
console.log('directory contents:', stdout)
执行
```Plain Text
zx demo.md
效果

a.mjs
import sh from 'tinysh'
sh.say('Hello, world!')
npm 包模式对于代码集成比较方便
pipe 模式的shell 处理
#!/usr/bin/env zx
import { $, echo } from 'zx'
$.nothrow = true
const list = $`ls -la`.pipe($`grep .mjs`)
echo(await list.text())
效果

zx 作为shell script 开发还是比较方便的,值得尝试下
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。