diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000..93b346d --- /dev/null +++ b/.babelrc @@ -0,0 +1,10 @@ +{ + "presets": [ + ["env", { + "targets": { + "node": 0.10 + } + }] + ], + "plugins": ["transform-runtime"] +} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 6e8ed5f..ba2397c 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ *.swp .DS_Store node_modules +dist .tern-port argo-HEAD argo-jscoverage diff --git a/.travis.yml b/.travis.yml index d5ca5f4..b41cd70 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,4 +4,18 @@ node_js: - "0.12" - "4.1.2" - "5" -sudo: false + - "6" +env: + global: + - TARGET_NODE_VERSION="6" + +script: + - npm install + - npm run build + - | + if [[ "${TRAVIS_NODE_VERSION}" == "${TARGET_NODE_VERSION}" ]]; then + npm test + fi + - cd dist + - ln -s ../node_modules node_modules + - npm test diff --git a/lib/api_resources/servers.js b/lib/api_resources/servers.js index 1a56ae1..bdfcd40 100644 --- a/lib/api_resources/servers.js +++ b/lib/api_resources/servers.js @@ -97,7 +97,7 @@ ServerResource.prototype.subscribe = function(env, next) { } var self = this; - parsed = url.parse(env.request.url, true); + var parsed = url.parse(env.request.url, true); var topic = decodeURIComponent(parsed.query.topic); if (topic) { diff --git a/lib/event_socket.js b/lib/event_socket.js index 8c0db8e..4c1c827 100644 --- a/lib/event_socket.js +++ b/lib/event_socket.js @@ -223,7 +223,7 @@ EventSocket.prototype.send = function(topic, data) { } try { - data = JSON.stringify(data); + arguments[1] = JSON.stringify(data); } catch (err) { console.error('ws JSON.stringify ', err); return; diff --git a/lib/web_socket.js b/lib/web_socket.js index 04692e2..b15a40e 100644 --- a/lib/web_socket.js +++ b/lib/web_socket.js @@ -24,7 +24,7 @@ var WebSocket = module.exports = function(address, httpOptions) { var self = this; if (httpOptions) { - for (k in httpOptions) { + for (var k in httpOptions) { self.options[k] = httpOptions[k]; } } diff --git a/package.json b/package.json index e670c6b..432d8ef 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "argo": "^1.0.0", "argo-formatter-siren": "0.0.0", "async": "^0.9.0", + "babel-runtime": "^6.23.0", "calypso": "^1.0.0", "calypso-level": "^0.5.0", "calypso-query-decompiler": "^0.4.0", @@ -33,6 +34,9 @@ "zetta-streams": "^0.3.0" }, "devDependencies": { + "babel-cli": "^6.24.1", + "babel-plugin-transform-runtime": "^6.23.0", + "babel-preset-env": "^1.3.3", "memdown": "^0.10.2", "mocha": "^1.20.1", "portscanner": "^1.0.0", @@ -40,6 +44,7 @@ "zetta-cluster": "^6.3.0" }, "scripts": { + "build": "babel . --out-dir dist --ignore node_modules/,dist/ --copy-files", "test": "./node_modules/.bin/mocha -R spec", "coverage": "bin/_coverage", "tag": "bin/_tag" diff --git a/test/fixture/scout_test_mocks.js b/test/fixture/scout_test_mocks.js index 4adc3d0..43b2bf8 100644 --- a/test/fixture/scout_test_mocks.js +++ b/test/fixture/scout_test_mocks.js @@ -83,7 +83,7 @@ MockPeerRegistry.prototype.add = function(peer, cb) { MockPeerRegistry.prototype.get = function(id, cb) { this.peers.forEach(function(peer) { if (peer.id === id) { - cb(null, JSON.stringify(peer)); + cb(null, peer); } }); }; diff --git a/test/test_event_streams.js b/test/test_event_streams.js index 06643fe..894a765 100644 --- a/test/test_event_streams.js +++ b/test/test_event_streams.js @@ -218,7 +218,7 @@ describe('Event Streams', function() { .server('hub', [Driver, Driver], ['cloud']) .server('hub2', [Driver, Driver], ['cloud']) .on('ready', function() { - app = cluster.servers['cloud']; + var app = cluster.servers['cloud']; urls.push('localhost:' + cluster.servers['cloud']._testPort); urls.push('localhost:' + cluster.servers['hub']._testPort); diff --git a/test/test_peer_connection_api.js b/test/test_peer_connection_api.js index fe5d1e0..e163c5d 100644 --- a/test/test_peer_connection_api.js +++ b/test/test_peer_connection_api.js @@ -297,6 +297,7 @@ describe('Peer Connection API', function() { describe('/peer-management update API', function() { var cloud = null; var localOne = null; + var localPort = null; var cloudPort = null; var localOnePort = null; var connectionId = null; diff --git a/test/test_peer_registry.js b/test/test_peer_registry.js index 51eccf8..d9cb22d 100644 --- a/test/test_peer_registry.js +++ b/test/test_peer_registry.js @@ -55,8 +55,8 @@ describe('Peer Registry', function() { it('should get peers by id', function(done) { var reg = new PeerRegistry(opts); - reg.save({ id: 012345 }, function() { - reg.get(012345, function(err, peer) { + reg.save({ id: 12345 }, function() { + reg.get(12345, function(err, peer) { assert(peer); done(); }); @@ -65,7 +65,7 @@ describe('Peer Registry', function() { it('should delete peers', function(done) { var reg = new PeerRegistry(opts); - var peer = { id: 0123456 }; + var peer = { id: 123456 }; reg.save(peer, function() { reg.remove(peer, function(err, peer) { assert.ifError(err); @@ -105,7 +105,7 @@ describe('Peer Registry', function() { it('should update existing peers', function(done) { var reg = new PeerRegistry(opts); - var peer = { id: 012345 }; + var peer = { id: 12345 }; reg.save(peer, function() { reg.add(peer, function(err, result) { diff --git a/test/test_query_api.js b/test/test_query_api.js index 92e1bf3..3190783 100644 --- a/test/test_query_api.js +++ b/test/test_query_api.js @@ -332,8 +332,10 @@ describe('Zetta Query Api', function() { }); describe('Non provisioned devices', function() { + var app = null; + beforeEach(function(done) { - machine = Scientist.create(TestDriver); + var machine = Scientist.create(TestDriver); Scientist.init(machine); reg.save(machine, function(err) { assert.ok(!err); diff --git a/test/test_stream_topic.js b/test/test_stream_topic.js index 590914c..6e96399 100644 --- a/test/test_stream_topic.js +++ b/test/test_stream_topic.js @@ -150,10 +150,10 @@ describe('Stream Topic', function() { describe('.match()', function() { - function matchTest(query, topic, eval) { - it('should return ' + eval + ' for query ' + query + ' on topic ' + topic, function() { + function matchTest(query, topic, eval_) { + it('should return ' + eval_ + ' for query ' + query + ' on topic ' + topic, function() { var t = StreamTopic.parse(query); - assert.equal(t.match(topic), eval); + assert.equal(t.match(topic), eval_); }) }