Skip to content

Commit 7906f05

Browse files
committed
Merge pull request libp2p#34 from dignifiedquire/dignfied
Use dignified.js
2 parents d7a0246 + cea42f5 commit 7906f05

19 files changed

+68
-95
lines changed

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,6 @@ node_modules
2929

3030

3131
coverage
32-
.jshintrc
33-
.jshintignore
32+
33+
dist
34+
lib

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
sudo: false
22
language: node_js
33
node_js:
4-
- "4.0"
4+
- 4
5+
- 5
56

67
# Make sure we have new NPM.
78
before_install:
Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
const Server = require('karma').Server
2-
const path = require('path')
1+
'use strict'
32

3+
const gulp = require('gulp')
44
const Peer = require('peer-info')
55
const Id = require('peer-id')
66
const WebSockets = require('libp2p-websockets')
7-
const Swarm = require('./../../src')
7+
8+
const Swarm = require('./src')
89
const multiaddr = require('multiaddr')
910

10-
var swarmA
11-
var swarmB
11+
let swarmA
12+
let swarmB
1213

13-
function createListeners (done) {
14+
gulp.task('test:browser:before', (done) => {
1415
function createListenerA (cb) {
1516
const b58IdA = 'QmWg2L4Fucx1x4KXJTfKHGixBJvveubzcd7DdhB2Mqwfh1'
1617
const peerA = new Peer(Id.createFromB58String(b58IdA))
@@ -35,7 +36,7 @@ function createListeners (done) {
3536
swarmB.handle('/echo/1.0.0', echo)
3637
}
3738

38-
var count = 0
39+
let count = 0
3940
const ready = () => ++count === 2 ? done() : null
4041

4142
createListenerA(ready)
@@ -44,22 +45,14 @@ function createListeners (done) {
4445
function echo (conn) {
4546
conn.pipe(conn)
4647
}
47-
}
48+
})
4849

49-
function stop (done) {
50-
var count = 0
50+
gulp.task('test:browser:after', (done) => {
51+
let count = 0
5152
const ready = () => ++count === 2 ? done() : null
5253

5354
swarmA.transport.close('ws', ready)
5455
swarmB.transport.close('ws', ready)
55-
}
56-
57-
function run (done) {
58-
const karma = new Server({
59-
configFile: path.join(__dirname, '../../karma.conf.js')
60-
}, done)
61-
62-
karma.start()
63-
}
56+
})
6457

65-
createListeners(() => run(() => stop(() => null)))
58+
require('dignified.js/gulp')(gulp)

karma.conf.js

Lines changed: 0 additions & 54 deletions
This file was deleted.

package.json

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22
"name": "libp2p-swarm",
33
"version": "0.9.2",
44
"description": "libp2p swarm implementation in JavaScript",
5-
"main": "src/index.js",
5+
"main": "lib/index.js",
6+
"jsnext:main": "src/index.js",
67
"scripts": {
7-
"test:node": "mocha tests/*-test.js",
8-
"test:browser": "node tests/browser-nodejs/test.js",
9-
"test": "npm run test:node && npm run test:browser",
10-
"coverage": "istanbul cover --print both -- _mocha tests/*-test.js",
11-
"lint": "standard"
8+
"lint": "dignified-lint",
9+
"build": "dignified-build",
10+
"test": "gulp test",
11+
"test:node": "gulp test:node",
12+
"test:browser": "gulp test:browser",
13+
"release": "dignified-release",
14+
"coverage": "istanbul cover --print both -- _mocha test/node.js"
1215
},
1316
"repository": {
1417
"type": "git",
@@ -34,31 +37,32 @@
3437
"bl": "^1.1.2",
3538
"buffer-loader": "0.0.1",
3639
"chai": "^3.5.0",
40+
"dignified.js": "^1.0.0",
41+
"gulp": "^3.9.1",
3742
"istanbul": "^0.4.2",
38-
"json-loader": "^0.5.4",
39-
"karma": "^0.13.22",
40-
"karma-chrome-launcher": "^0.2.2",
41-
"karma-firefox-launcher": "^0.1.7",
42-
"karma-mocha": "^0.2.2",
43-
"karma-spec-reporter": "0.0.24",
44-
"karma-webpack": "^1.7.0",
4543
"libp2p-multiplex": "^0.2.1",
4644
"libp2p-spdy": "^0.2.3",
4745
"libp2p-tcp": "^0.4.0",
4846
"libp2p-websockets": "^0.2.1",
49-
"mocha": "^2.4.5",
5047
"multiaddr": "^1.3.0",
5148
"peer-id": "^0.6.0",
5249
"peer-info": "^0.6.0",
5350
"pre-commit": "^1.1.2",
54-
"standard": "^6.0.7",
55-
"stream-pair": "^1.0.3",
56-
"webpack": "^2.1.0-beta.4"
51+
"stream-pair": "^1.0.3"
5752
},
5853
"dependencies": {
5954
"duplex-passthrough": "github:diasdavid/duplex-passthrough",
6055
"ip-address": "^5.0.2",
6156
"multistream-select": "^0.6.1",
6257
"protocol-buffers-stream": "^1.2.0"
58+
},
59+
"dignified": {
60+
"webpack": {
61+
"resolve": {
62+
"alias": {
63+
"node-forge": "../deps/forge.bundle.js"
64+
}
65+
}
66+
}
6367
}
6468
}

src/identify.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* established, so a conn can be reused
66
*/
77

8+
'use strict'
9+
810
const multistream = require('multistream-select')
911
const fs = require('fs')
1012
const path = require('path')

src/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
const multistream = require('multistream-select')
24
const identify = require('./identify')
35
const DuplexPassThrough = require('duplex-passthrough')

tests/00-basic-test.js renamed to test/00-basic.node.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* eslint-env mocha */
2+
'use strict'
23

34
const expect = require('chai').expect
45

tests/01-transport-tcp-test.js renamed to test/01-transport-tcp.node.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* eslint-env mocha */
2+
'use strict'
23

34
const expect = require('chai').expect
45

tests/02-transport-utp-test.js renamed to test/02-transport-utp.node.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* eslint-env mocha */
2+
'use strict'
23

34
describe('transport - utp', function () {
45
this.timeout(10000)

tests/03-transport-websockets-test.js renamed to test/03-transport-websockets.node.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* eslint-env mocha */
2+
'use strict'
23

34
const expect = require('chai').expect
45

tests/04-muxing-multiplex-test.js renamed to test/04-muxing-multiplex.node.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* eslint-env mocha */
2+
'use strict'
23

34
const expect = require('chai').expect
45

tests/05-muxing-spdy-test.js renamed to test/05-muxing-spdy.node.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* eslint-env mocha */
2+
'use strict'
23

34
const expect = require('chai').expect
45

tests/06-conn-upgrade-secio-test.js renamed to test/06-conn-upgrade-secio.node.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* eslint-env mocha */
2+
'use strict'
23

34
describe('secio conn upgrade (on TCP)', function () {
45
this.timeout(20000)

tests/07-conn-upgrade-tls-test.js renamed to test/07-conn-upgrade-tls.node.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* eslint-env mocha */
2+
'use strict'
23

34
describe('tls conn upgrade (on TCP)', function () {
45
before((done) => { done() })

tests/08-swarm-without-muxing-test.js renamed to test/08-swarm-without-muxing.node.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* eslint-env mocha */
2+
'use strict'
23

34
const expect = require('chai').expect
45

tests/09-swarm-with-muxing-test.js renamed to test/09-swarm-with-muxing.node.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* eslint-env mocha */
2+
'use strict'
23

34
const expect = require('chai').expect
45

tests/browser-nodejs/browser.js renamed to test/browser.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
/* eslint-env mocha */
2+
'use strict'
23

34
const expect = require('chai').expect
45
const multiaddr = require('multiaddr')
56
const Id = require('peer-id')
67
const Peer = require('peer-info')
7-
const Swarm = require('./../../src')
88
const WebSockets = require('libp2p-websockets')
99
const bl = require('bl')
1010

11+
const Swarm = require('../src')
12+
1113
describe('basics', () => {
1214
it('throws on missing peerInfo', (done) => {
1315
expect(Swarm).to.throw(Error)

test/node.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/* eslint-env mocha */
2+
'use strict'
3+
4+
const fs = require('fs')
5+
6+
describe('libp2p-swarm', () => {
7+
fs.readdirSync(__dirname)
8+
.filter((file) => file.match(/\.node\.js$/))
9+
.forEach((file) => {
10+
require(`./${file}`)
11+
})
12+
})

0 commit comments

Comments
 (0)