Skip to content

Commit

Permalink
v4.0.1 No longer use coffee-script/register
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonwiram / royvandewater committed Jun 28, 2017
1 parent 0dd9612 commit ebc7aba
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 43 deletions.
1 change: 0 additions & 1 deletion index.coffee

This file was deleted.

2 changes: 0 additions & 2 deletions index.js

This file was deleted.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"name": "meshblu-firehose-socket.io",
"version": "4.0.0",
"version": "4.0.1",
"description": "Meshblu Firehose Client for socket.io",
"main": "index.js",
"main": "./dist/firehose-socket-io.js",
"browser": {
"./index.js": "./dist/bundle.js"
},
"scripts": {
"coverage": "nyc npm test",
"mocha:json": "env NPM_ENV=test mocha --reporter json > coverage/mocha.json",
"build": "webpack --config webpack.config.lib.js",
"build": "webpack --config webpack.config.lib.js && coffee --compile --output dist/ --map src/*.coffee",
"bundle": "webpack --config webpack.config.global.js -p",
"test": "mocha"
},
Expand Down Expand Up @@ -46,7 +46,7 @@
"eventemitter2": "^2.2.1",
"lodash": "^4.17.4",
"socket.io-client": "^1.7.2",
"srv-failover": "^1.3.0"
"srv-failover": "^2.0.0"
},
"nyc": {
"cache": true,
Expand Down
9 changes: 4 additions & 5 deletions src/firehose-socket-io.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ class MeshbluFirehoseSocketIO extends EventEmitter2
'upgradeError'
]

constructor: ({meshbluConfig, @transports}, dependencies={}) ->
constructor: ({meshbluConfig, @transports, @srvFailover}) ->
super wildcard: true
{@dns} = dependencies

throw new Error('MeshbluFirehoseSocketIO: meshbluConfig is required') unless meshbluConfig?
throw new Error('MeshbluFirehoseSocketIO: meshbluConfig.uuid is required') unless meshbluConfig.uuid?
Expand All @@ -44,7 +43,7 @@ class MeshbluFirehoseSocketIO extends EventEmitter2
if secure == false
srvProtocol = 'socket-io-ws'
urlProtocol = 'ws'
@srvFailover = new SrvFailover {domain, service, protocol: srvProtocol, urlProtocol}
@srvFailover ?= new SrvFailover {domain, service, protocol: srvProtocol, urlProtocol}
else
@_assertNoSrv {service, domain, secure}
protocol ?= 'https'
Expand Down Expand Up @@ -87,7 +86,7 @@ class MeshbluFirehoseSocketIO extends EventEmitter2
return if @closing
@_reconnect()

@socket.once 'connect_error', (error) =>
@socket.once 'connect_error', =>
@srvFailover.markBadUrl baseUrl, ttl: 60000 if @srvFailover?
@_reconnect()

Expand All @@ -100,7 +99,7 @@ class MeshbluFirehoseSocketIO extends EventEmitter2
bindEvents: =>
@socket.on 'message', @_onMessage

@socket.on 'error', (error) =>
@socket.on 'error', =>
@emit 'socket-io:error', arguments...

@socket.on 'close', =>
Expand Down
22 changes: 7 additions & 15 deletions test/resolve-srv-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
{expect} = require 'chai'
sinon = require 'sinon'
SocketIO = require 'socket.io'
Meshblu = require '../src/firehose-socket-io'
Firehose = require '../src/firehose-socket-io'

describe 'Meshblu', ->
describe 'Firehose', ->
beforeEach ->
@server = new SocketIO 34715

Expand All @@ -20,27 +20,19 @@ describe 'Meshblu', ->
uuid: 'foo'
token: 'toalsk'
}
expect(=> new Meshblu {meshbluConfig}).to.throw(
expect(=> new Firehose {meshbluConfig}).to.throw(
'hostname parameter is only valid when the parameter resolveSrv is false'
)

describe 'when constructed with resolveSrv true, secure false, and nothing else', ->
beforeEach ->
@dns = resolveSrv: sinon.stub()

beforeEach 'create sut', ->
meshbluConfig = {resolveSrv: true, secure: false, uuid: '1', token: '1'}
dependencies = {@dns, @WebSocket}

@sut = new Meshblu {meshbluConfig}, dependencies
@srvFailover = {}
@sut = new Firehose { meshbluConfig, @srvFailover }

describe 'when connect is called', ->
beforeEach 'making the request', (done) ->
@dns.resolveSrv.withArgs('_meshblu-firehose._socket-io-ws.octoblu.com').yields null, [{
name: 'localhost'
port: 34715
priority: 1
weight: 100
}]
@srvFailover.resolveUrl = sinon.stub().withArgs('_meshblu-firehose._socket-io-ws.octoblu.com').yields null, 'ws://localhost:34715'
@sut.on 'error', done
@sut.once 'connect', done
@sut.connect()
Expand Down
2 changes: 1 addition & 1 deletion webpack.config.lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var webpack = require('webpack');
module.exports = {
devtool: 'cheap-eval',
entry: [
'./index.coffee'
'./src/firehose-socket-io.coffee'
],
output: {
libraryTarget: 'commonjs2',
Expand Down
19 changes: 4 additions & 15 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -418,10 +418,6 @@ coffee-script@^1.12.2:
version "1.12.2"
resolved "https://registry.yarnpkg.com/coffee-script/-/coffee-script-1.12.2.tgz#0d4cbdee183f650da95419570c4929d08ef91376"

coffee-script@^1.12.4:
version "1.12.4"
resolved "https://registry.yarnpkg.com/coffee-script/-/coffee-script-1.12.4.tgz#fe1bced97fe1fb3927b998f2b45616e0658be1ff"

combined-stream@^1.0.5, combined-stream@~1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.5.tgz#938370a57b4a51dea2c77c15d5c5fdf895164009"
Expand Down Expand Up @@ -1116,12 +1112,6 @@ isobject@^2.0.0:
dependencies:
isarray "1.0.0"

isomorphic-dns@^1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/isomorphic-dns/-/isomorphic-dns-1.0.4.tgz#6092ffe29aa46615ef3cc1c154c01fe575d8d1fb"
dependencies:
http-dns "^3.0.1"

isstream@~0.1.2:
version "0.1.2"
resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a"
Expand Down Expand Up @@ -2025,12 +2015,11 @@ spdx-license-ids@^1.0.2:
version "1.2.2"
resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-1.2.2.tgz#c9df7a3424594ade6bd11900d596696dc06bac57"

srv-failover@^1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/srv-failover/-/srv-failover-1.3.0.tgz#149cae87d307198ced8c7162a33407935f1c8b31"
srv-failover@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/srv-failover/-/srv-failover-2.0.0.tgz#cb5e6233e587e774356861c3d4e480b77c82756b"
dependencies:
coffee-script "^1.12.4"
isomorphic-dns "^1.0.4"
http-dns "^3.0.1"
lodash "^4.17.4"

sshpk@^1.7.0:
Expand Down

0 comments on commit ebc7aba

Please sign in to comment.