/
test.ts
39 lines (29 loc) · 1.06 KB
/
test.ts
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
import {awk, escBash, json, nl, txt, split0, escDash} from './index'
async function main(args: string[]): Promise<number | void> {
const text = await txt`echo ${"foo\nbar"}`
console.log(text)
const lines = await nl`echo ${"foo\nbar"}`
console.log(lines)
const pkg = await json`jq -c .name package.json`
console.log(pkg)
const files = await split0`find . -maxdepth 1 -type f -print0`
console.log(files)
const inception = await txt`sh -c ${escDash`echo ${`foo bar`}`}`
console.log(inception)
const table = await awk`cat table.txt`
console.log(table)
const ascii = await txt`printf '%q' ${Array.from({length:128}, (_,i) => String.fromCodePoint(i)).join('')}`
console.log(ascii)
// TODO: passthru``
}
main(process.argv.slice(process.argv.findIndex(f => f === __filename) + 1))
.then(exitCode => {
if(typeof exitCode === 'number') {
process.exitCode = exitCode
}
}, err => {
if(err != null) {
console.error(err)
}
process.exitCode = 255
})