This repository has been archived by the owner on May 10, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy patha.js
50 lines (43 loc) · 1.46 KB
/
a.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/** @type {import('./src')} */
const tish = require('./dist')
const { $, Command, stdout, stderr, stdouterr, CommandError } = tish
main()
async function main() {
try {
await $('git a')
} catch (err) {
console.error(err)
const { status, command } = err
console.error(await stderr(command))
}
try {
// console.log(await stdout($('git log --oneline').pipe($('grep fix'))))
// for await (const log of $('git log --oneline').pipe($('head'))) {
// const hash = log.slice(0, 7)
// const message = log.slice(8)
// console.log({ hash, message })
// }
// const out = await stdout($('git log --').pipe($('head')))
// console.log(out)
// const out = await stdout(
// $('echo hello, world.').pipe($('grep -o world.')).pipe($('xargs echo hello,'))
// )
// console.log(out)
} catch (err) {
if (err instanceof CommandError) {
const { status, command } = err
console.log('catched: status=%s', command._id)
await stdouterr(command)
.then((str) => {
console.log('done')
console.log('==========')
console.log(str)
})
.catch((err) => {
console.log('err')
console.log('==========')
console.log(err)
})
}
}
}