-
Notifications
You must be signed in to change notification settings - Fork 267
/
test.js
executable file
·64 lines (52 loc) · 1.66 KB
/
test.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
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env node
const { exec, spawn, spawnSync } = require('child_process')
function sleep(ms) {
return new Promise(resolve => {
setTimeout(resolve, ms)
})
}
const addErrorLogs = thing => {
thing.stderr.on('data', data => {
console.log(`stderr: ${data}`)
})
thing.on('error', error => {
console.log(`stderr: ${error.message}`)
})
}
const start = async () => {
const ganache = spawn('npx', ['ganache-cli', '-b 1'], {
cwd: '.'
})
addErrorLogs(ganache)
const rmdata = spawnSync('rm', ['-rf', 'data'], {
cwd: '../graph-node/docker'
})
console.log(rmdata.stderr.toString('utf8'), rmdata.error)
const docker = spawn('docker-compose', ['up'], {
cwd: '../graph-node/docker'
})
addErrorLogs(docker)
const cypressOpen = spawn('yarn', ['cypress:open'], { cwd: '.' })
addErrorLogs(cypressOpen)
console.log('sleeping...')
await sleep(1000 * 30)
console.log('awake')
const preTest = spawnSync('yarn', ['preTest'], { cwd: '.' })
console.log(preTest.stderr.toString('utf8'), preTest.error)
console.log('preTest')
const subgraph = spawnSync('yarn', ['subgraph'], { cwd: '.' })
console.log(subgraph.stderr.toString('utf8'), subgraph.error)
console.log('subgraph')
const setup = spawnSync('yarn', ['setup'], { cwd: '../ens-subgraph' })
console.log(setup.stderr.toString('utf8'), setup.error)
console.log('setup')
const yarnStart = spawn('yarn', ['start:test'], { cwd: '.' })
addErrorLogs(yarnStart)
console.log('launching web app, ctrl+C to kill')
process.on('SIGINT', () => {
ganache.kill('SIGINT')
docker.kill('SIGINT')
console.log('press ctrl+C again once you see "stderr: 2"')
})
}
start()