From 30fc8258b7898ad0a8019c7067c3ddcf5d8faed0 Mon Sep 17 00:00:00 2001 From: Dmitriy Ryajov Date: Thu, 14 Dec 2017 00:05:38 -0600 Subject: [PATCH] feat: porting to new aegir (#70) * feat: porting to new aegir * chore: adding missing dep * feat: add global timeout to avoid touching interface-stream-muxer * fix: use Buffer.from * chore: timeout * fix: timeouts --- gulpfile.js => .aegir.js | 19 ++++++++++++------- package.json | 25 +++++++++++++------------ test/browser.js | 4 ++-- test/multiplex.spec.js | 6 +++--- 4 files changed, 30 insertions(+), 24 deletions(-) rename gulpfile.js => .aegir.js (78%) diff --git a/gulpfile.js b/.aegir.js similarity index 78% rename from gulpfile.js rename to .aegir.js index ed4aef2..b0484cc 100644 --- a/gulpfile.js +++ b/.aegir.js @@ -1,6 +1,5 @@ 'use strict' -const gulp = require('gulp') const WSlibp2p = require('libp2p-websockets') const multiaddr = require('multiaddr') const pull = require('pull-stream') @@ -8,8 +7,7 @@ const pull = require('pull-stream') const multiplex = require('./src') let listener - -gulp.task('test:browser:before', (done) => { +const boot = (done) => { const ws = new WSlibp2p() const mh = multiaddr('/ip4/127.0.0.1/tcp/9095/ws') listener = ws.createListener((transportSocket) => { @@ -21,10 +19,17 @@ gulp.task('test:browser:before', (done) => { }) listener.listen(mh, done) -}) +} -gulp.task('test:browser:after', (done) => { +const shutdown = (done) => { listener.close(done) -}) +} -require('aegir/gulp')(gulp) +module.exports = { + hooks: { + browser: { + pre: boot, + post: shutdown + } + } +} diff --git a/package.json b/package.json index 1ee3d7f..8b25803 100644 --- a/package.json +++ b/package.json @@ -4,16 +4,16 @@ "description": "multiplex implementation wrapper that is compatible with libp2p Stream Muxer expected interface", "main": "src/index.js", "scripts": { - "lint": "gulp lint", - "build": "gulp build", - "test": "gulp test", - "test:node": "gulp test:node", - "test:browser": "gulp test:browser", - "release": "gulp release", - "release-minor": "gulp release --type minor", - "release-major": "gulp release --type major", - "coverage": "gulp coverage", - "coverage-publish": "aegir-coverage publish" + "lint": "aegir lint", + "build": "aegir build", + "test": "aegir test -t node -t browser", + "test:node": "aegir test -t node", + "test:browser": "aegir test -t browser", + "release": "aegir release -t node -t browser", + "release-minor": "aegir release --type minor -t node -t browser", + "release-major": "aegir release --type major -t node -t browser", + "coverage": "aegir coverage", + "coverage-publish": "aegir coverage --provider coveralls" }, "repository": { "type": "git", @@ -29,7 +29,7 @@ }, "homepage": "https://github.com/libp2p/js-libp2p-multiplex#readme", "devDependencies": { - "aegir": "^11.0.2", + "aegir": "^12.2.0", "chai": "^4.1.2", "dirty-chai": "^2.0.1", "interface-stream-muxer": "~0.5.7", @@ -44,6 +44,7 @@ "pull-catch": "^1.0.0", "pull-stream": "^3.6.0", "pull-stream-to-stream": "^1.3.4", + "pump": "^2.0.0", "stream-to-pull-stream": "^1.7.2" }, "contributors": [ @@ -55,4 +56,4 @@ "Victor Bjelkholm ", "greenkeeperio-bot " ] -} \ No newline at end of file +} diff --git a/test/browser.js b/test/browser.js index ab22f15..ecc0fb5 100644 --- a/test/browser.js +++ b/test/browser.js @@ -28,14 +28,14 @@ describe('browser-server', () => { conn, pull.collect((err, chunks) => { expect(err).to.not.exist() - expect(chunks).to.be.eql([new Buffer('hey')]) + expect(chunks).to.be.eql([Buffer.from('hey')]) pull(pull.empty(), conn) }) ) }) pull( - pull.values([new Buffer('hey')]), + pull.values([Buffer.from('hey')]), muxedConn.newStream(), pull.onEnd(done) ) diff --git a/test/multiplex.spec.js b/test/multiplex.spec.js index 345a3a8..e67a996 100644 --- a/test/multiplex.spec.js +++ b/test/multiplex.spec.js @@ -45,7 +45,7 @@ describe('multiplex-generic', () => { conn, pull.collect((err, res) => { expect(err).to.not.exist() - expect(res).to.eql([new Buffer('hello')]) + expect(res).to.eql([Buffer.from('hello')]) done() }) ) @@ -58,11 +58,11 @@ describe('multiplex-generic', () => { const conn = listener.newStream() pull( - pull.values([new Buffer('hello')]), + pull.values([Buffer.from('hello')]), conn, pull.collect((err, res) => { expect(err).to.not.exist() - expect(res).to.eql([new Buffer('hello')]) + expect(res).to.eql([Buffer.from('hello')]) done() }) )