-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.js
50 lines (39 loc) · 1.23 KB
/
example.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
let {
cat,
echo,
exec,
git,
invalidCommand,
vim,
} = require('.');
async function main() {
// This is never run due to lazy promise behavior:
/* await */ invalidCommand().toString();
await echo(`$ echo "Hello, world." | sed "s/world/my friend/"`);
await echo('Hello, world.').sed('s/world/my friend/');
await echo();
await echo(`$ echo "Hello, world." >> hellos`);
await echo('Hello, world.').appendTo('hellos');
await echo();
await echo(`$ vim hellos`);
await vim('hellos');
await echo();
await echo(`$ cat hellos # With console.log(await cat(...).toString())`);
console.log(await cat('hellos').toString());
await echo(`$ cat example.js | grep example`);
await cat('example.js').grep('example');
await echo();
await echo(`$ notify-send "i hackz ur computerz"`);
await exec('notify-send', `i hackz ur computerz`);
await echo();
await echo(`$ git show HEAD | head -n 1`);
await git('show', 'HEAD').head({ n: 1 });
await echo();
await echo(`$ git diff --cached | head -n 1`);
await git('diff', { cached: true }).head({ n: 1 });
await echo();
await echo(`$ git diff | head -n 1`);
await git('diff', { cached: false }).head({ n: 1 });
await echo();
}
main().catch(console.error);