其他
一经开源就爆了!谷歌这个脚本工具注定要火
开源最前线(ID:OpenSourceTop) 猿妹整编
项目地址:https://github.com/google/zx
npm i -g zx
#!/usr/bin/env zx
chmod +x ./script.mjs
./script.mjs
zx ./script.mjs
let count = parseInt(await $`ls -1 | wc -l`)
console.log(`Files count: ${count}`)
let hosts = [...]
await Promise.all(hosts.map(host =>
$`rsync -azP ./src ${host}:/var/www`
))
try {
await $`exit 1`
} catch (p) {
console.log(`Exit code: ${p.exitCode}`)
console.log(`Error: ${p.stderr}`)
}
class ProcessOutput {
readonly exitCode: number
readonly stdout: string
readonly stderr: string
toString(): string
}
cd('/tmp')
await $`pwd` // outputs /tmp
let resp = await fetch('http://wttr.in')
if (resp.ok) {
console.log(await resp.text())
}
type QuestionOptions = { choices: string[] }
function question(query?: string, options?: QuestionOptions): Promise<string>
let username = await question('What is your username? ')
let token = await question('Choose env variable: ', {
choices: Object.keys(process.env)
})
function sleep(ms: number): Promise
await sleep(1000)
console.log(chalk.blue('Hello world!'))
console.log(chalk.blue('Hello world!'))
推荐阅读:
谷歌这个牛逼的开源数据库,我居然等到它上Github热榜才发现
1534K Star!排名前十的 10 大前端开源项目都开源了些啥?一起来看看吧!