-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.js
52 lines (38 loc) · 947 Bytes
/
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
51
52
const {
run,
commit,
maybe
} = require('./lib.js');
(async function () {
// Get environmental variables
const {
TARGET_BRANCH = 'master'
} = process.env;
await run('rm /testFile').catch(() => {
console.log('An error occurred');
});
const canPush = await maybe(`git pull origin ${TARGET_BRANCH} --dry-run`);
if (canPush.failed) {
console.error(`Couldn't pull ${TARGET_BRANCH} got code ${canPush.code}`);
}
await commit('touch file1');
const echoTest = await commit('echo "test"');
console.log(echoTest);
await commit('touch file2', {
cwd: './test'
});
await maybe('touch', {
cwd: './test'
});
const sleeps = await Promise.all([
maybe('sleep 5'),
maybe('sleep 5')
]);
console.log('sleeps', sleeps);
const elements = await maybe('ls /');
for (let element of elements.values) {
const stat = await maybe(`stat /${element}`);
console.log(stat.output);
}
console.log('done');
})();