|
2 | 2 |
|
3 | 3 | const fs = require('fs')
|
4 | 4 | const run = require('subcomandante')
|
5 |
| -const async = require('async') |
| 5 | +const series = require('run-series') |
6 | 6 | const ipfs = require('ipfs-api')
|
7 | 7 | const multiaddr = require('multiaddr')
|
8 | 8 | const rimraf = require('rimraf')
|
@@ -30,17 +30,15 @@ function findIpfsExecutable () {
|
30 | 30 | }
|
31 | 31 |
|
32 | 32 | function configureNode (node, conf, done) {
|
33 |
| - if (Object.keys(conf).length > 0) { |
34 |
| - async.forEachOfSeries(conf, (value, key, cb) => { |
35 |
| - const env = {env: node.env} |
36 |
| - |
37 |
| - run(node.exec, ['config', key, '--json', JSON.stringify(value)], env) |
38 |
| - .on('error', cb) |
39 |
| - .on('end', cb) |
40 |
| - }, done) |
41 |
| - } else { |
42 |
| - done() |
43 |
| - } |
| 33 | + const keys = Object.keys(conf) |
| 34 | + series(keys.map((key) => (cb) => { |
| 35 | + const value = conf[key] |
| 36 | + const env = {env: node.env} |
| 37 | + |
| 38 | + run(node.exec, ['config', key, '--json', JSON.stringify(value)], env) |
| 39 | + .on('error', cb) |
| 40 | + .on('end', cb) |
| 41 | + }), done) |
44 | 42 | }
|
45 | 43 |
|
46 | 44 | // Consistent error handling
|
@@ -126,17 +124,17 @@ module.exports = class Node {
|
126 | 124 |
|
127 | 125 | this.subprocess = run(this.exec, ['daemon'], {env: this.env})
|
128 | 126 | .on('error', (err) => {
|
129 |
| - if ((err + '').match('daemon is running')) { |
| 127 | + if (String(err).match('daemon is running')) { |
130 | 128 | // we're good
|
131 | 129 | done(null, ipfs(conf.Addresses.API))
|
132 |
| - } else if ((err + '').match('non-zero exit code')) { |
| 130 | + } else if (String(err).match('non-zero exit code')) { |
133 | 131 | // ignore when kill -9'd
|
134 | 132 | } else {
|
135 | 133 | done(err)
|
136 | 134 | }
|
137 | 135 | })
|
138 | 136 | .on('data', (data) => {
|
139 |
| - const match = (data + '').trim().match(/API server listening on (.*)/) |
| 137 | + const match = String(data).trim().match(/API server listening on (.*)/) |
140 | 138 | if (match) {
|
141 | 139 | this.apiAddr = match[1]
|
142 | 140 | const addr = multiaddr(this.apiAddr).nodeAddress()
|
|
0 commit comments