Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

refactor: aegir pre and post hooks on both node and browser #2646

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 18 additions & 34 deletions .aegir.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
'use strict'

const IPFSFactory = require('ipfsd-ctl')
const parallel = require('async/parallel')
const MockPreloadNode = require('./test/utils/mock-preload-node')
const EchoServer = require('interface-ipfs-core/src/utils/echo-http-server')
const callbackify = require('callbackify')

const ipfsdServer = IPFSFactory.createServer()
const preloadNode = MockPreloadNode.createNode()
Expand All @@ -29,40 +27,26 @@ module.exports = {
},
hooks: {
node: {
pre: (cb) => {
parallel([
(cb) => callbackify(preloadNode.start)(cb),
(cb) => echoServer.start(cb)
], cb)
},
post: (cb) => {
parallel([
(cb) => callbackify(preloadNode.stop)(cb),
(cb) => echoServer.stop(cb)
], cb)
}
pre: () => Promise.all([
preloadNode.start(),
echoServer.start()
]),
post: () => Promise.all([
preloadNode.stop(),
echoServer.stop()
])
},
browser: {
pre: (cb) => {
parallel([
(cb) => {
ipfsdServer.start()
cb()
},
(cb) => callbackify(preloadNode.start)(cb),
(cb) => echoServer.start(cb)
], cb)
},
post: (cb) => {
parallel([
(cb) => {
ipfsdServer.stop()
cb()
},
(cb) => callbackify(preloadNode.stop)(cb),
(cb) => echoServer.stop(cb)
], cb)
}
pre: () => Promise.all([
ipfsdServer.start(),
preloadNode.start(),
echoServer.start()
]),
post: () => Promise.all([
ipfsdServer.stop(),
preloadNode.stop(),
echoServer.stop()
])
}
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@
"execa": "^3.0.0",
"form-data": "^3.0.0",
"hat": "0.0.3",
"interface-ipfs-core": "^0.121.0",
"interface-ipfs-core": "^0.124.0",
"ipfs-interop": "^0.1.1",
"ipfsd-ctl": "^0.47.2",
"libp2p-websocket-star": "~0.10.2",
Expand Down