diff --git a/.travis.yml b/.travis.yml index 9d678dd..534297f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,38 +1,53 @@ -sudo: false -language: node_js +anguage: node_js +cache: npm +stages: + - check + - test + - cov -matrix: - include: - - node_js: 4 - env: CXX=g++-4.8 - - node_js: 6 - env: - - SAUCE=true - - CXX=g++-4.8 - - node_js: stable - env: CXX=g++-4.8 +node_js: + - '12' + - '10' + +os: + - linux + - osx + - windows -# Make sure we have new NPM. -before_install: - - npm install -g npm +script: npx nyc -s npm run test:node -- --bail +after_success: npx nyc report --reporter=text-lcov > coverage.lcov && npx codecov -script: - - npm run lint - - npm test - - npm run coverage - - make test +jobs: + include: + - stage: check + script: + - npx aegir commitlint --travis + - npx aegir dep-check + - npm run lint -before_script: - - export DISPLAY=:99.0 - - sh -e /etc/init.d/xvfb start + - stage: test + name: chrome + addons: + chrome: stable + script: npx aegir test -t browser -t webworker -after_success: - - npm run coverage-publish + - stage: test + name: firefox + addons: + firefox: latest + script: npx aegir test -t browser -t webworker -- --browsers FirefoxHeadless + + - stage: test + name: electron-main + os: osx + script: + - npx aegir test -t electron-main --bail + + - stage: test + name: electron-renderer + os: osx + script: + - npx aegir test -t electron-renderer --bail -addons: - firefox: 'latest' - apt: - sources: - - ubuntu-toolchain-r-test - packages: - - g++-4.8 +notifications: + email: false \ No newline at end of file diff --git a/circle.yml b/circle.yml deleted file mode 100644 index 434211a..0000000 --- a/circle.yml +++ /dev/null @@ -1,12 +0,0 @@ -machine: - node: - version: stable - -dependencies: - pre: - - google-chrome --version - - wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add - - - sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' - - sudo apt-get update - - sudo apt-get --only-upgrade install google-chrome-stable - - google-chrome --version diff --git a/package.json b/package.json index 99026bd..27d8743 100644 --- a/package.json +++ b/package.json @@ -4,16 +4,16 @@ "description": "Parse all the varints in a Buffer (for when there are varints everywhere)", "main": "src/index.js", "scripts": { - "lint": "aegir-lint", - "build": "aegir-build", - "test": "aegir-test", - "test:node": "aegir-test --env node", - "test:browser": "aegir-test --env browser", - "release": "aegir-release", - "release-minor": "aegir-release --type minor", - "release-major": "aegir-release --type major", - "coverage": "aegir-coverage", - "coverage-publish": "aegir-coverage publish" + "lint": "aegir lint", + "build": "aegir build", + "test": "aegir test", + "test:node": "aegir test -t node", + "test:browser": "aegir test -t browser", + "release": "aegir release", + "release-minor": "aegir release --type minor", + "release-major": "aegir release --type major", + "coverage": "aegir coverage", + "coverage-publish": "aegir coverage publish" }, "pre-commit": [ "lint", @@ -24,11 +24,13 @@ "npm": ">=3.0.0" }, "dependencies": { + "is-buffer": "^2.0.4", "varint": "^5.0.0" }, "devDependencies": { - "aegir": "^9.3.0", - "chai": "^3.5.0", + "aegir": "^21.9.0", + "buffer": "^5.6.0", + "chai": "^4.2.0", "pre-commit": "^1.2.2" }, "repository": { @@ -48,4 +50,4 @@ "contributors": [ "David Dias " ] -} \ No newline at end of file +} diff --git a/src/index.js b/src/index.js index 4f80211..068704d 100644 --- a/src/index.js +++ b/src/index.js @@ -1,13 +1,14 @@ 'use strict' const varint = require('varint') +const isBuffer = require('is-buffer') module.exports = (buf) => { - if (!Buffer.isBuffer(buf)) { + if (!isBuffer(buf)) { throw new Error('arg needs to be a buffer') } - let result = [] + const result = [] while (buf.length > 0) { const num = varint.decode(buf) diff --git a/test/varint-decoder.spec.js b/test/varint-decoder.spec.js index 4f4e15f..43dc396 100644 --- a/test/varint-decoder.spec.js +++ b/test/varint-decoder.spec.js @@ -2,25 +2,25 @@ 'use strict' const expect = require('chai').expect - +const { Buffer } = require('buffer') const vd = require('../src') describe('varint-decoder', () => { it('decode 1 varint', () => { - const buf = new Buffer('05', 'hex') + const buf = Buffer.from('05', 'hex') const arr = vd(buf) expect(arr[0]).to.equal(5) }) it('decode 2 varints', () => { - const buf = new Buffer('000a', 'hex') + const buf = Buffer.from('000a', 'hex') const arr = vd(buf) expect(arr[0]).to.equal(0) expect(arr[1]).to.equal(10) }) it('decode 3 varints', () => { - const buf = new Buffer('0b0c03', 'hex') + const buf = Buffer.from('0b0c03', 'hex') const arr = vd(buf) expect(arr[0]).to.equal(11) expect(arr[1]).to.equal(12) @@ -28,13 +28,13 @@ describe('varint-decoder', () => { }) it('decode 1 long varint', () => { - const buf = new Buffer('c801', 'hex') + const buf = Buffer.from('c801', 'hex') const arr = vd(buf) expect(arr[0]).to.equal(200) }) it('decode a mix of long and short', () => { - const buf = new Buffer('96130208b90a', 'hex') + const buf = Buffer.from('96130208b90a', 'hex') const arr = vd(buf) expect(arr[0]).to.equal(2454) expect(arr[1]).to.equal(2) @@ -42,4 +42,3 @@ describe('varint-decoder', () => { expect(arr[3]).to.equal(1337) }) }) -