From 09ebc5604b5f20ee58744da4fcd89e74b04a1551 Mon Sep 17 00:00:00 2001 From: dignifiedquire Date: Mon, 8 Feb 2016 09:43:14 +0100 Subject: [PATCH] refactor: Update dependencies to latest --- gulpfile.js | 2 +- package.json | 8 ++++--- src/api/add.js | 2 +- src/api/block.js | 2 +- src/api/cat.js | 2 +- src/api/commands.js | 2 +- src/api/config.js | 2 +- src/api/dht.js | 6 ++--- src/api/diag.js | 2 +- src/api/id.js | 2 +- src/api/log.js | 4 ++-- src/api/ls.js | 2 +- src/api/mount.js | 2 +- src/api/name.js | 2 +- src/api/object.js | 2 +- src/api/pin.js | 2 +- src/api/ping.js | 4 ++-- src/api/refs.js | 2 +- src/api/swarm.js | 2 +- src/api/update.js | 2 +- src/api/version.js | 2 +- src/load-commands.js | 2 +- tasks/build.js | 4 ++-- tasks/daemons.js | 18 +++++++------- tasks/release.js | 10 ++++---- tasks/test.js | 11 +++++---- test/api/add.spec.js | 26 ++++++++++---------- test/api/block.spec.js | 14 +++++------ test/api/cat.spec.js | 50 +++++++++++++++++++++++---------------- test/api/commands.spec.js | 8 +++---- test/api/config.spec.js | 20 +++++++++------- test/api/dht.spec.js | 12 +++++----- test/api/diag.spec.js | 8 +++---- test/api/id.spec.js | 4 ++-- test/api/log.spec.js | 16 ++++++------- test/api/ls.spec.js | 14 +++++------ test/api/name.spec.js | 8 +++---- test/api/object.spec.js | 50 +++++++++++++++++++++++---------------- test/api/pin.spec.js | 14 +++++------ test/api/ping.spec.js | 6 ++--- test/api/refs.spec.js | 4 ++-- test/api/swarm.spec.js | 6 ++--- test/api/version.spec.js | 12 +++++----- test/setup.js | 4 ++-- 44 files changed, 201 insertions(+), 176 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 4d38d7855..5dcffd35d 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -5,7 +5,7 @@ const runSequence = require('run-sequence') require('require-dir')('tasks') -gulp.task('default', done => { +gulp.task('default', (done) => { runSequence( 'lint', 'test', diff --git a/package.json b/package.json index 2603b0433..4b0ada131 100644 --- a/package.json +++ b/package.json @@ -24,19 +24,21 @@ }, "devDependencies": { "babel-core": "^6.1.21", - "babel-eslint": "^5.0.0-beta6", + "babel-eslint": "^5.0.0-beta9", "babel-loader": "^6.2.0", "babel-plugin-transform-runtime": "^6.1.18", "babel-preset-es2015": "^6.0.15", "babel-runtime": "^6.3.19", "chai": "^3.4.1", "concurrently": "^1.0.0", - "eslint-config-standard": "^4.4.0", + "eslint": "^2.0.0-rc.0", + "eslint-config-standard": "^5.1.0", + "eslint-plugin-promise": "^1.0.8", "eslint-plugin-standard": "^1.3.1", "glob-stream": "5.3.1", "gulp": "^3.9.0", "gulp-bump": "^1.0.0", - "gulp-eslint": "^1.0.0", + "gulp-eslint": "^2.0.0-rc-3", "gulp-filter": "^3.0.1", "gulp-git": "^1.6.0", "gulp-load-plugins": "^1.0.0", diff --git a/src/api/add.js b/src/api/add.js index 0083458eb..3d0a33d6e 100644 --- a/src/api/add.js +++ b/src/api/add.js @@ -1,6 +1,6 @@ const Wreck = require('wreck') -module.exports = send => { +module.exports = (send) => { return function add (files, opts, cb) { if (typeof (opts) === 'function' && cb === undefined) { cb = opts diff --git a/src/api/block.js b/src/api/block.js index fba2cfc59..2d8bc7b12 100644 --- a/src/api/block.js +++ b/src/api/block.js @@ -2,7 +2,7 @@ const argCommand = require('../cmd-helpers').argCommand -module.exports = send => { +module.exports = (send) => { return { get: argCommand(send, 'block/get'), stat: argCommand(send, 'block/stat'), diff --git a/src/api/cat.js b/src/api/cat.js index 8da4a3324..6a9639688 100644 --- a/src/api/cat.js +++ b/src/api/cat.js @@ -2,6 +2,6 @@ const argCommand = require('../cmd-helpers').argCommand -module.exports = send => { +module.exports = (send) => { return argCommand(send, 'cat') } diff --git a/src/api/commands.js b/src/api/commands.js index a49430071..18eaee4d5 100644 --- a/src/api/commands.js +++ b/src/api/commands.js @@ -2,6 +2,6 @@ const command = require('../cmd-helpers').command -module.exports = send => { +module.exports = (send) => { return command(send, 'commands') } diff --git a/src/api/config.js b/src/api/config.js index 7c5ff3e98..3ba502084 100644 --- a/src/api/config.js +++ b/src/api/config.js @@ -2,7 +2,7 @@ const argCommand = require('../cmd-helpers').argCommand -module.exports = send => { +module.exports = (send) => { return { get: argCommand(send, 'config'), set (key, value, opts, cb) { diff --git a/src/api/dht.js b/src/api/dht.js index 5c70d0897..aa02da5ce 100644 --- a/src/api/dht.js +++ b/src/api/dht.js @@ -2,7 +2,7 @@ const argCommand = require('../cmd-helpers').argCommand -module.exports = send => { +module.exports = (send) => { return { findprovs: argCommand(send, 'dht/findprovs'), get (key, opts, cb) { @@ -37,8 +37,8 @@ module.exports = send => { return send('dht/get', key, opts) .then( - res => handleResult(done, null, res), - err => handleResult(done, err) + (res) => handleResult(done, null, res), + (err) => handleResult(done, err) ) } diff --git a/src/api/diag.js b/src/api/diag.js index 1286cf686..d4f6ac2c6 100644 --- a/src/api/diag.js +++ b/src/api/diag.js @@ -2,7 +2,7 @@ const command = require('../cmd-helpers').command -module.exports = send => { +module.exports = (send) => { return { net: command(send, 'diag/net'), sys: command(send, 'diag/sys') diff --git a/src/api/id.js b/src/api/id.js index b9df9f0fc..ab4d44e8d 100644 --- a/src/api/id.js +++ b/src/api/id.js @@ -1,6 +1,6 @@ 'use strict' -module.exports = send => { +module.exports = (send) => { return function id (idParam, cb) { if (typeof idParam === 'function') { cb = idParam diff --git a/src/api/log.js b/src/api/log.js index b246a8a09..1c85767d8 100644 --- a/src/api/log.js +++ b/src/api/log.js @@ -2,12 +2,12 @@ const ndjson = require('ndjson') -module.exports = send => { +module.exports = (send) => { return { tail (cb) { if (typeof cb !== 'function' && typeof Promise !== 'undefined') { return send('log/tail', null, {}, null, false) - .then(res => res.pipe(ndjson.parse())) + .then((res) => res.pipe(ndjson.parse())) } return send('log/tail', null, {}, null, false, (err, res) => { diff --git a/src/api/ls.js b/src/api/ls.js index f87b7cc50..4f109b6fe 100644 --- a/src/api/ls.js +++ b/src/api/ls.js @@ -2,6 +2,6 @@ const argCommand = require('../cmd-helpers').argCommand -module.exports = send => { +module.exports = (send) => { return argCommand(send, 'ls') } diff --git a/src/api/mount.js b/src/api/mount.js index 6e600869f..917fa0b90 100644 --- a/src/api/mount.js +++ b/src/api/mount.js @@ -1,6 +1,6 @@ 'use strict' -module.exports = send => { +module.exports = (send) => { return function mount (ipfs, ipns, cb) { if (typeof ipfs === 'function') { cb = ipfs diff --git a/src/api/name.js b/src/api/name.js index 1385e4b9e..70e7b72b9 100644 --- a/src/api/name.js +++ b/src/api/name.js @@ -2,7 +2,7 @@ const argCommand = require('../cmd-helpers').argCommand -module.exports = send => { +module.exports = (send) => { return { publish: argCommand(send, 'name/publish'), resolve: argCommand(send, 'name/resolve') diff --git a/src/api/object.js b/src/api/object.js index ff5d7ba3f..00cc63838 100644 --- a/src/api/object.js +++ b/src/api/object.js @@ -2,7 +2,7 @@ const argCommand = require('../cmd-helpers').argCommand -module.exports = send => { +module.exports = (send) => { return { get: argCommand(send, 'object/get'), put (file, encoding, cb) { diff --git a/src/api/pin.js b/src/api/pin.js index 00655c6d5..e48facf47 100644 --- a/src/api/pin.js +++ b/src/api/pin.js @@ -1,6 +1,6 @@ 'use strict' -module.exports = send => { +module.exports = (send) => { return { add (hash, opts, cb) { if (typeof opts === 'function') { diff --git a/src/api/ping.js b/src/api/ping.js index f4261e01e..f2853a675 100644 --- a/src/api/ping.js +++ b/src/api/ping.js @@ -1,10 +1,10 @@ 'use strict' -module.exports = send => { +module.exports = (send) => { return function ping (id, cb) { if (typeof cb !== 'function' && typeof Promise !== 'undefined') { return send('ping', id, {n: 1}, null) - .then(res => res[1]) + .then((res) => res[1]) } return send('ping', id, { n: 1 }, null, function (err, res) { diff --git a/src/api/refs.js b/src/api/refs.js index bd39fa4ba..1788512f7 100644 --- a/src/api/refs.js +++ b/src/api/refs.js @@ -2,7 +2,7 @@ const cmds = require('../cmd-helpers') -module.exports = send => { +module.exports = (send) => { const refs = cmds.argCommand(send, 'refs') refs.local = cmds.command(send, 'refs/local') diff --git a/src/api/swarm.js b/src/api/swarm.js index 9e42d0e41..7619b8630 100644 --- a/src/api/swarm.js +++ b/src/api/swarm.js @@ -2,7 +2,7 @@ const cmds = require('../cmd-helpers') -module.exports = send => { +module.exports = (send) => { return { peers: cmds.command(send, 'swarm/peers'), connect: cmds.argCommand(send, 'swarm/connect') diff --git a/src/api/update.js b/src/api/update.js index 13c057023..5eca2c3ec 100644 --- a/src/api/update.js +++ b/src/api/update.js @@ -2,7 +2,7 @@ const command = require('../cmd-helpers').command -module.exports = send => { +module.exports = (send) => { return { apply: command(send, 'update'), check: command(send, 'update/check'), diff --git a/src/api/version.js b/src/api/version.js index 3447b1a20..9221b6275 100644 --- a/src/api/version.js +++ b/src/api/version.js @@ -2,6 +2,6 @@ const command = require('../cmd-helpers').command -module.exports = send => { +module.exports = (send) => { return command(send, 'version') } diff --git a/src/load-commands.js b/src/load-commands.js index f6be472ac..087f73976 100644 --- a/src/load-commands.js +++ b/src/load-commands.js @@ -32,7 +32,7 @@ function loadCommands (send) { const files = requireCommands() const cmds = {} - Object.keys(files).forEach(file => { + Object.keys(files).forEach((file) => { cmds[file] = files[file](send) }) diff --git a/tasks/build.js b/tasks/build.js index f3ef434c5..573673c92 100644 --- a/tasks/build.js +++ b/tasks/build.js @@ -8,7 +8,7 @@ const runSequence = require('run-sequence') const config = require('./config') -gulp.task('clean', done => { +gulp.task('clean', (done) => { rimraf('./dist', done) }) @@ -30,7 +30,7 @@ gulp.task('build:minified', () => { .pipe(gulp.dest('dist/')) }) -gulp.task('build', ['clean'], done => { +gulp.task('build', ['clean'], (done) => { runSequence( 'build:nonminified', 'build:minified', diff --git a/tasks/daemons.js b/tasks/daemons.js index 6bebbfd35..7d127edcc 100644 --- a/tasks/daemons.js +++ b/tasks/daemons.js @@ -2,17 +2,18 @@ const gulp = require('gulp') const fs = require('fs') +const path = require('path') let daemons -gulp.task('daemons:start', done => { - startDisposableDaemons(d => { +gulp.task('daemons:start', (done) => { + startDisposableDaemons((d) => { daemons = d done() }) }) -gulp.task('daemons:stop', done => { +gulp.task('daemons:stop', (done) => { stopDisposableDaemons(daemons, () => { daemons = null done() @@ -33,7 +34,8 @@ function startDisposableDaemons (callback) { function finish () { counter++ if (counter === 3) { - fs.writeFileSync(__dirname + '/../test/tmp-disposable-nodes-addrs.json', JSON.stringify(apiAddrs)) + const targetPath = path.join(__dirname, '/../test/tmp-disposable-nodes-addrs.json') + fs.writeFileSync(targetPath, JSON.stringify(apiAddrs)) callback(ipfsNodes) } } @@ -48,11 +50,11 @@ function startDisposableDaemons (callback) { console.log(' ipfs init done - (bootstrap and mdns off) - ' + key) - ipfsNodes[key].setConfig('Bootstrap', null, err => { + ipfsNodes[key].setConfig('Bootstrap', null, (err) => { if (err) { throw err } - ipfsNodes[key].setConfig('Discovery', '{}', err => { + ipfsNodes[key].setConfig('Discovery', '{}', (err) => { if (err) { throw err } @@ -62,7 +64,7 @@ function startDisposableDaemons (callback) { 'Access-Control-Allow-Origin': ['*'] } } - ipfsNodes[key].setConfig('API', JSON.stringify(headers), err => { + ipfsNodes[key].setConfig('API', JSON.stringify(headers), (err) => { if (err) { throw err } @@ -97,7 +99,7 @@ function stopDisposableDaemons (daemons, callback) { function stopIPFSNode (daemons, key, cb) { let nodeStopped - daemons[key].stopDaemon(err => { + daemons[key].stopDaemon((err) => { if (err) { throw err } diff --git a/tasks/release.js b/tasks/release.js index 7fb97c36e..d750229b8 100644 --- a/tasks/release.js +++ b/tasks/release.js @@ -20,7 +20,7 @@ function npmPublish (done) { const publish = spawn('npm', ['publish']) publish.stdout.pipe(process.stdout) publish.stderr.pipe(process.stderr) - publish.on('close', code => { + publish.on('close', (code) => { if (code !== 0) return fail(`npm publish. Exiting with ${code}.`) $.util.log('Published to npm.') @@ -54,10 +54,10 @@ gulp.task('release:bump', () => { .pipe($.tagVersion()) }) -gulp.task('release:push', done => { +gulp.task('release:push', (done) => { const remote = $.util.remote || 'origin' $.util.log('Pushing to git...') - $.git.push(remote, 'master', {args: '--tags'}, err => { + $.git.push(remote, 'master', {args: '--tags'}, (err) => { if (err) return fail(err.message) $.util.log(`Pushed to git ${remote}:master`) @@ -65,7 +65,7 @@ gulp.task('release:push', done => { }) }) -gulp.task('release:publish', done => { +gulp.task('release:publish', (done) => { $.git.status({args: '-s'}, (err, stdout) => { if (err) return fail(err.message) @@ -80,7 +80,7 @@ gulp.task('release:publish', done => { }) }) -gulp.task('release', done => { +gulp.task('release', (done) => { runSequence( 'lint', 'test', diff --git a/tasks/test.js b/tasks/test.js index 0c32dfb16..83c4d361b 100644 --- a/tasks/test.js +++ b/tasks/test.js @@ -4,12 +4,13 @@ const gulp = require('gulp') const Server = require('karma').Server const $ = require('gulp-load-plugins')() const runSequence = require('run-sequence') +const path = require('path') const config = require('./config') require('./daemons') -gulp.task('test', done => { +gulp.task('test', (done) => { runSequence( 'test:node', 'test:browser', @@ -17,7 +18,7 @@ gulp.task('test', done => { ) }) -gulp.task('test:node', done => { +gulp.task('test:node', (done) => { runSequence( 'daemons:start', 'mocha', @@ -26,7 +27,7 @@ gulp.task('test:node', done => { ) }) -gulp.task('test:browser', done => { +gulp.task('test:browser', (done) => { runSequence( 'daemons:start', 'karma', @@ -45,9 +46,9 @@ gulp.task('mocha', () => { })) }) -gulp.task('karma', done => { +gulp.task('karma', (done) => { new Server({ - configFile: __dirname + '/../karma.conf.js', + configFile: path.join(__dirname, '/../karma.conf.js'), singleRun: true }, done).start() }) diff --git a/test/api/add.spec.js b/test/api/add.spec.js index 1432e299e..aefd401ec 100644 --- a/test/api/add.spec.js +++ b/test/api/add.spec.js @@ -6,14 +6,14 @@ const Readable = require('stream').Readable const isNode = !global.window -const testfilePath = __dirname + '/../testfile.txt' +const testfilePath = path.join(__dirname, '/../testfile.txt') let testfile let testfileBig if (isNode) { - testfile = require('fs').readFileSync(__dirname + '/../testfile.txt') - testfileBig = require('fs').createReadStream(__dirname + '/../15mb.random', { bufferSize: 128 }) - // testfileBig = require('fs').createReadStream(__dirname + '/../100mb.random', { bufferSize: 128 }) + testfile = require('fs').readFileSync(path.join(__dirname, '/../testfile.txt')) + testfileBig = require('fs').createReadStream(path.join(__dirname, '/../15mb.random'), { bufferSize: 128 }) + // testfileBig = require('fs').createReadStream(path.join(__dirname, '/../100mb.random'), { bufferSize: 128 }) } else { testfile = require('raw!../testfile.txt') // browser goes nuts with a 100mb in memory @@ -21,7 +21,7 @@ if (isNode) { } describe('.add', () => { - it('add file', done => { + it('add file', (done) => { if (!isNode) { return done() } @@ -43,7 +43,7 @@ describe('.add', () => { }) }) - it('add buffer', done => { + it('add buffer', (done) => { let buf = new Buffer(testfile) apiClients['a'].add(buf, (err, res) => { expect(err).to.not.exist @@ -53,7 +53,7 @@ describe('.add', () => { }) }) - it('add BIG buffer', done => { + it('add BIG buffer', (done) => { if (!isNode) { return done() } @@ -66,7 +66,7 @@ describe('.add', () => { }) }) - it('add path', done => { + it('add path', (done) => { if (!isNode) { return done() } @@ -80,8 +80,8 @@ describe('.add', () => { }) }) - it('add a nested dir', done => { - apiClients['a'].add(__dirname + '/../test-folder', { recursive: true }, (err, res) => { + it('add a nested dir', (done) => { + apiClients['a'].add(path.join(__dirname, '/../test-folder'), { recursive: true }, (err, res) => { if (isNode) { expect(err).to.not.exist @@ -95,7 +95,7 @@ describe('.add', () => { }) }) - it('add stream', done => { + it('add stream', (done) => { const stream = new Readable() stream.push('Hello world') stream.push(null) @@ -108,7 +108,7 @@ describe('.add', () => { }) }) - it('add url', done => { + it('add url', (done) => { const url = 'https://raw.githubusercontent.com/ipfs/js-ipfs-api/2a9cc63d7427353f2145af6b1a768a69e67c0588/README.md' apiClients['a'].add(url, (err, res) => { expect(err).to.not.exist @@ -123,7 +123,7 @@ describe('.add', () => { it('add buffer', () => { let buf = new Buffer(testfile) return apiClients['a'].add(buf) - .then(res => { + .then((res) => { expect(res).to.have.length(1) expect(res[0]).to.have.property('Hash', 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP') }) diff --git a/test/api/block.spec.js b/test/api/block.spec.js index cedc9bd9f..eadeedec9 100644 --- a/test/api/block.spec.js +++ b/test/api/block.spec.js @@ -4,7 +4,7 @@ describe('.block', () => { const blorbKey = 'QmPv52ekjS75L4JmHpXVeuJ5uX2ecSfSZo88NSyxwA3rAQ' const blorb = Buffer('blorb') - it('block.put', done => { + it('block.put', (done) => { apiClients['a'].block.put(blorb, (err, res) => { expect(err).to.not.exist expect(res).to.have.a.property('Key', 'QmPv52ekjS75L4JmHpXVeuJ5uX2ecSfSZo88NSyxwA3rAQ') @@ -12,7 +12,7 @@ describe('.block', () => { }) }) - it('block.get', done => { + it('block.get', (done) => { apiClients['a'].block.get(blorbKey, (err, res) => { expect(err).to.not.exist @@ -26,7 +26,7 @@ describe('.block', () => { }) }) - it('block.stat', done => { + it('block.stat', (done) => { apiClients['a'].block.stat(blorbKey, (err, res) => { expect(err).to.not.exist expect(res).to.have.property('Key') @@ -38,14 +38,14 @@ describe('.block', () => { describe('promise', () => { it('block.put', () => { return apiClients['a'].block.put(blorb) - .then(res => { + .then((res) => { expect(res).to.have.a.property('Key', 'QmPv52ekjS75L4JmHpXVeuJ5uX2ecSfSZo88NSyxwA3rAQ') }) }) - it('block.get', done => { + it('block.get', (done) => { return apiClients['a'].block.get(blorbKey) - .then(res => { + .then((res) => { let buf = '' res .on('data', function (data) { buf += data }) @@ -58,7 +58,7 @@ describe('.block', () => { it('block.stat', () => { return apiClients['a'].block.stat(blorbKey) - .then(res => { + .then((res) => { expect(res).to.have.property('Key') expect(res).to.have.property('Size') }) diff --git a/test/api/cat.spec.js b/test/api/cat.spec.js index 04cf9bb17..a170b164a 100644 --- a/test/api/cat.spec.js +++ b/test/api/cat.spec.js @@ -1,34 +1,40 @@ 'use strict' +const path = require('path') const streamEqual = require('stream-equal') let testfile let testfileBig if (isNode) { - testfile = require('fs').readFileSync(__dirname + '/../testfile.txt') - testfileBig = require('fs').createReadStream(__dirname + '/../15mb.random', { bufferSize: 128 }) + testfile = require('fs').readFileSync(path.join(__dirname, '/../testfile.txt')) + testfileBig = require('fs').createReadStream(path.join(__dirname, '/../15mb.random'), { bufferSize: 128 }) } else { testfile = require('raw!../testfile.txt') } describe('.cat', () => { - it('cat', done => { - apiClients['a'].cat('Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP', (err, res) => { - expect(err).to.not.exist + it('cat', (done) => { + apiClients['a'] + .cat('Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP', (err, res) => { + expect(err).to.not.exist - let buf = '' - res - .on('error', err => { throw err }) - .on('data', data => buf += data) - .on('end', () => { - expect(buf).to.be.equal(testfile.toString()) - done() - }) - }) + let buf = '' + res + .on('error', (err) => { + throw err + }) + .on('data', (data) => { + buf += data + }) + .on('end', () => { + expect(buf).to.be.equal(testfile.toString()) + done() + }) + }) }) - it('cat BIG file', done => { + it('cat BIG file', (done) => { if (!isNode) { return done() } @@ -36,7 +42,7 @@ describe('.cat', () => { apiClients['a'].cat('Qme79tX2bViL26vNjPsF3DP1R9rMKMvnPYJiKTTKPrXJjq', (err, res) => { expect(err).to.not.exist - testfileBig = require('fs').createReadStream(__dirname + '/../15mb.random', { bufferSize: 128 }) + testfileBig = require('fs').createReadStream(path.join(__dirname, '/../15mb.random'), { bufferSize: 128 }) // Do not blow out the memory of nodejs :) streamEqual(res, testfileBig, (err, equal) => { @@ -48,13 +54,17 @@ describe('.cat', () => { }) describe('promise', () => { - it('cat', done => { + it('cat', (done) => { return apiClients['a'].cat('Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP') - .then(res => { + .then((res) => { let buf = '' res - .on('error', err => { throw err }) - .on('data', data => buf += data) + .on('error', (err) => { + throw err + }) + .on('data', (data) => { + buf += data + }) .on('end', () => { expect(buf).to.be.equal(testfile.toString()) done() diff --git a/test/api/commands.spec.js b/test/api/commands.spec.js index a76e23c36..e1447862a 100644 --- a/test/api/commands.spec.js +++ b/test/api/commands.spec.js @@ -1,7 +1,7 @@ 'use strict' describe('.commands', () => { - it('lists commands', done => { + it('lists commands', (done) => { apiClients['a'].commands((err, res) => { expect(err).to.not.exist expect(res).to.exist @@ -12,9 +12,9 @@ describe('.commands', () => { describe('promise', () => { it('lists commands', () => { return apiClients['a'].commands() - .then(res => { - expect(res).to.exist - }) + .then((res) => { + expect(res).to.exist + }) }) }) }) diff --git a/test/api/config.spec.js b/test/api/config.spec.js index 2241b6e2c..d8029e6f3 100644 --- a/test/api/config.spec.js +++ b/test/api/config.spec.js @@ -1,7 +1,9 @@ 'use strict' +const path = require('path') + describe('.config', () => { - it('.config.{set, get}', done => { + it('.config.{set, get}', (done) => { const confKey = 'arbitraryKey' const confVal = 'arbitraryVal' @@ -15,7 +17,7 @@ describe('.config', () => { }) }) - it('.config.show', done => { + it('.config.show', (done) => { apiClients['c'].config.show((err, res) => { expect(err).to.not.exist expect(res).to.exist @@ -23,12 +25,12 @@ describe('.config', () => { }) }) - it('.config.replace', done => { + it('.config.replace', (done) => { if (!isNode) { return done() } - apiClients['c'].config.replace(__dirname + '/../r-config.json', (err, res) => { + apiClients['c'].config.replace(path.join(__dirname, '/../r-config.json'), (err, res) => { expect(err).to.not.exist expect(res).to.be.equal(null) done() @@ -41,17 +43,17 @@ describe('.config', () => { const confVal = 'arbitraryVal' return apiClients['a'].config.set(confKey, confVal) - .then(res => { + .then((res) => { return apiClients['a'].config.get(confKey) }) - .then(res => { + .then((res) => { expect(res).to.have.a.property('Value', confVal) }) }) it('.config.show', () => { return apiClients['c'].config.show() - .then(res => { + .then((res) => { expect(res).to.exist }) }) @@ -61,8 +63,8 @@ describe('.config', () => { return } - return apiClients['c'].config.replace(__dirname + '/../r-config.json') - .then(res => { + return apiClients['c'].config.replace(path.join(__dirname, '/../r-config.json')) + .then((res) => { expect(res).to.be.equal(null) }) }) diff --git a/test/api/dht.spec.js b/test/api/dht.spec.js index ff6e7c5d3..d3154d673 100644 --- a/test/api/dht.spec.js +++ b/test/api/dht.spec.js @@ -2,14 +2,14 @@ describe('.dht', () => { it('returns an error when getting a non-existent key from the DHT', - done => { + (done) => { apiClients['a'].dht.get('non-existent', {timeout: '100ms'}, (err, value) => { expect(err).to.be.an.instanceof(Error) done() }) }) - it('puts and gets a key value pair in the DHT', done => { + it('puts and gets a key value pair in the DHT', (done) => { apiClients['a'].dht.put('scope', 'interplanetary', (err, res) => { expect(err).to.not.exist @@ -28,7 +28,7 @@ describe('.dht', () => { }) }) - it('.dht.findprovs', done => { + it('.dht.findprovs', (done) => { apiClients['a'].dht.findprovs('Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP', (err, res) => { expect(err).to.not.exist @@ -40,21 +40,21 @@ describe('.dht', () => { describe('promise', () => { it('returns an error when getting a non-existent key from the DHT', () => { return apiClients['a'].dht.get('non-existent', {timeout: '100ms'}) - .catch(err => { + .catch((err) => { expect(err).to.be.an.instanceof(Error) }) }) it('puts a key value pair in the DHT', () => { return apiClients['a'].dht.put('scope', 'interplanetary') - .then(res => { + .then((res) => { expect(res).to.be.an('array') }) }) it('.dht.findprovs', () => { return apiClients['a'].dht.findprovs('Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP') - .then(res => { + .then((res) => { expect(res).to.be.an('array') }) }) diff --git a/test/api/diag.spec.js b/test/api/diag.spec.js index e598c7d7f..63dc9ed24 100644 --- a/test/api/diag.spec.js +++ b/test/api/diag.spec.js @@ -1,7 +1,7 @@ 'use strict' describe('.diag', () => { - it('.diag.net', done => { + it('.diag.net', (done) => { apiClients['a'].diag.net((err, res) => { expect(err).to.not.exist expect(res).to.exist @@ -9,7 +9,7 @@ describe('.diag', () => { }) }) - it('.diag.sys', done => { + it('.diag.sys', (done) => { apiClients['a'].diag.sys((err, res) => { expect(err).to.not.exist expect(res).to.exist @@ -22,14 +22,14 @@ describe('.diag', () => { describe('promise', () => { it('.diag.net', () => { return apiClients['a'].diag.net() - .then(res => { + .then((res) => { expect(res).to.exist }) }) it('.diag.sys', () => { return apiClients['a'].diag.sys() - .then(res => { + .then((res) => { expect(res).to.exist expect(res).to.have.a.property('memory') expect(res).to.have.a.property('diskinfo') diff --git a/test/api/id.spec.js b/test/api/id.spec.js index c32b459e2..fef9e5b72 100644 --- a/test/api/id.spec.js +++ b/test/api/id.spec.js @@ -1,7 +1,7 @@ 'use strict' describe('.id', () => { - it('id', done => { + it('id', (done) => { apiClients['a'].id((err, res) => { expect(err).to.not.exist expect(res).to.have.a.property('ID') @@ -13,7 +13,7 @@ describe('.id', () => { describe('promise', () => { it('id', () => { return apiClients['a'].id() - .then(res => { + .then((res) => { expect(res).to.have.a.property('ID') expect(res).to.have.a.property('PublicKey') }) diff --git a/test/api/log.spec.js b/test/api/log.spec.js index 40ca49595..7e89c3c1c 100644 --- a/test/api/log.spec.js +++ b/test/api/log.spec.js @@ -1,13 +1,13 @@ 'use strict' describe('.log', () => { - it('.log.tail', done => { + it('.log.tail', (done) => { const req = apiClients['a'].log.tail((err, res) => { expect(err).to.not.exist expect(req).to.exist - res.once('data', obj => { + res.once('data', (obj) => { expect(obj).to.be.an('object') done() }) @@ -15,14 +15,14 @@ describe('.log', () => { }) describe('promise', () => { - it('.log.tail', done => { + it('.log.tail', (done) => { return apiClients['a'].log.tail() - .then(res => { - res.once('data', obj => { - expect(obj).to.be.an('object') - done() + .then((res) => { + res.once('data', (obj) => { + expect(obj).to.be.an('object') + done() + }) }) - }) }) }) }) diff --git a/test/api/ls.spec.js b/test/api/ls.spec.js index 59ce03611..8ebe3cdff 100644 --- a/test/api/ls.spec.js +++ b/test/api/ls.spec.js @@ -39,16 +39,16 @@ describe('ls', function () { if (!isNode) return return apiClients['a'].ls('QmSzLpCVbWnEm3XoTWnv6DT6Ju5BsVoLhzvxKXZeQ2cmdg') - .then(res => { - expect(res).to.have.a.property('Objects') - expect(res.Objects[0]).to.have.a.property('Links') - expect(res.Objects[0]).to.have.property('Hash', 'QmSzLpCVbWnEm3XoTWnv6DT6Ju5BsVoLhzvxKXZeQ2cmdg') - }) + .then((res) => { + expect(res).to.have.a.property('Objects') + expect(res.Objects[0]).to.have.a.property('Links') + expect(res.Objects[0]).to.have.property('Hash', 'QmSzLpCVbWnEm3XoTWnv6DT6Ju5BsVoLhzvxKXZeQ2cmdg') + }) }) it('should correctly handle a nonexisting hash', () => { return apiClients['a'].ls('surelynotavalidhashheh?') - .catch(err => { + .catch((err) => { expect(err).to.exist }) }) @@ -57,7 +57,7 @@ describe('ls', function () { if (!isNode) return return apiClients['a'].ls('QmTDH2RXGn8XyDAo9YyfbZAUXwL1FCr44YJCN9HBZmL9Gj/folder_that_isnt_there') - .catch(err => { + .catch((err) => { expect(err).to.exist }) }) diff --git a/test/api/name.spec.js b/test/api/name.spec.js index a834f96dd..1bac2fffe 100644 --- a/test/api/name.spec.js +++ b/test/api/name.spec.js @@ -3,7 +3,7 @@ describe('.name', () => { let name - it('.name.publish', done => { + it('.name.publish', (done) => { apiClients['a'].name.publish('Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP', (err, res) => { expect(err).to.not.exist name = res @@ -12,7 +12,7 @@ describe('.name', () => { }) }) - it('.name.resolve', done => { + it('.name.resolve', (done) => { apiClients['a'].name.resolve(name.Name, (err, res) => { expect(err).to.not.exist expect(res).to.exist @@ -26,7 +26,7 @@ describe('.name', () => { describe('promise', () => { it('.name.publish', () => { return apiClients['a'].name.publish('Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP') - .then(res => { + .then((res) => { name = res expect(name).to.exist }) @@ -34,7 +34,7 @@ describe('.name', () => { it('.name.resolve', () => { return apiClients['a'].name.resolve(name.Name) - .then(res => { + .then((res) => { expect(res).to.exist expect(res).to.be.eql({ Path: '/ipfs/' + name.Value diff --git a/test/api/object.spec.js b/test/api/object.spec.js index dca7abdb9..1263ce37c 100644 --- a/test/api/object.spec.js +++ b/test/api/object.spec.js @@ -6,7 +6,7 @@ describe('.object', () => { const testPatchObject = Buffer(JSON.stringify({Data: 'new test data'})) const testPatchObjectHash = 'QmWJDtdQWQSajQPx1UVAGWKaSGrHVWdjnrNhbooHP7LuF2' - it('object.put', done => { + it('object.put', (done) => { apiClients['a'].object.put(testObject, 'json', (err, res) => { expect(err).to.not.exist expect(res).to.have.a.property('Hash', testObjectHash) @@ -15,7 +15,7 @@ describe('.object', () => { }) }) - it('object.get', done => { + it('object.get', (done) => { apiClients['a'].object.get(testObjectHash, (err, res) => { expect(err).to.not.exist expect(res).to.have.a.property('Data', 'testdata') @@ -24,14 +24,18 @@ describe('.object', () => { }) }) - it('object.data', done => { + it('object.data', (done) => { apiClients['a'].object.data(testObjectHash, (err, res) => { expect(err).to.not.exist let buf = '' res - .on('error', err => { throw err }) - .on('data', data => buf += data) + .on('error', (err) => { + throw err + }) + .on('data', (data) => { + buf += data + }) .on('end', () => { expect(buf).to.equal('testdata') done() @@ -39,7 +43,7 @@ describe('.object', () => { }) }) - it('object.stat', done => { + it('object.stat', (done) => { apiClients['a'].object.stat(testObjectHash, (err, res) => { expect(err).to.not.exist expect(res).to.be.eql({ @@ -54,7 +58,7 @@ describe('.object', () => { }) }) - it('object.links', done => { + it('object.links', (done) => { apiClients['a'].object.links(testObjectHash, (err, res) => { expect(err).to.not.exist @@ -66,7 +70,7 @@ describe('.object', () => { }) }) - it('object.patch', done => { + it('object.patch', (done) => { apiClients['a'].object.put(testPatchObject, 'json', (err, res) => { expect(err).to.not.exist apiClients['a'].object.patch(testObjectHash, ['add-link', 'next', testPatchObjectHash], (err, res) => { @@ -91,7 +95,7 @@ describe('.object', () => { }) }) - it('object.new', done => { + it('object.new', (done) => { apiClients['a'].object.new('unixfs-dir', (err, res) => { expect(err).to.not.exist expect(res).to.deep.equal({ @@ -105,7 +109,7 @@ describe('.object', () => { describe('promise', () => { it('object.put', () => { return apiClients['a'].object.put(testObject, 'json') - .then(res => { + .then((res) => { expect(res).to.have.a.property('Hash', testObjectHash) expect(res.Links).to.be.empty }) @@ -113,19 +117,23 @@ describe('.object', () => { it('object.get', () => { return apiClients['a'].object.get(testObjectHash) - .then(res => { + .then((res) => { expect(res).to.have.a.property('Data', 'testdata') expect(res.Links).to.be.empty }) }) - it('object.data', done => { + it('object.data', (done) => { return apiClients['a'].object.data(testObjectHash) - .then(res => { + .then((res) => { let buf = '' res - .on('error', err => { throw err }) - .on('data', data => buf += data) + .on('error', (err) => { + throw err + }) + .on('data', (data) => { + buf += data + }) .on('end', () => { expect(buf).to.equal('testdata') done() @@ -135,7 +143,7 @@ describe('.object', () => { it('object.stat', () => { return apiClients['a'].object.stat(testObjectHash) - .then(res => { + .then((res) => { expect(res).to.be.eql({ Hash: 'QmPTkMuuL6PD8L2SwTwbcs1NPg14U8mRzerB1ZrrBrkSDD', NumLinks: 0, @@ -149,7 +157,7 @@ describe('.object', () => { it('object.links', () => { return apiClients['a'].object.links(testObjectHash) - .then(res => { + .then((res) => { expect(res).to.be.eql({ Hash: 'QmPTkMuuL6PD8L2SwTwbcs1NPg14U8mRzerB1ZrrBrkSDD', Links: [] @@ -159,18 +167,18 @@ describe('.object', () => { it('object.patch', () => { return apiClients['a'].object.put(testPatchObject, 'json') - .then(res => { + .then((res) => { return apiClients['a'].object .patch(testObjectHash, ['add-link', 'next', testPatchObjectHash]) }) - .then(res => { + .then((res) => { expect(res).to.be.eql({ Hash: 'QmZFdJ3CQsY4kkyQtjoUo8oAzsEs5BNguxBhp8sjQMpgkd', Links: null }) return apiClients['a'].object.get(res.Hash) }) - .then(res => { + .then((res) => { expect(res).to.be.eql({ Data: 'testdata', Links: [{ @@ -184,7 +192,7 @@ describe('.object', () => { it('object.new', () => { return apiClients['a'].object.new('unixfs-dir') - .then(res => { + .then((res) => { expect(res).to.deep.equal({ Hash: 'QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn', Links: null diff --git a/test/api/pin.spec.js b/test/api/pin.spec.js index f018fdfce..33f7682f6 100644 --- a/test/api/pin.spec.js +++ b/test/api/pin.spec.js @@ -1,7 +1,7 @@ 'use strict' describe('.pin', () => { - it('.pin.add', done => { + it('.pin.add', (done) => { apiClients['b'].pin.add('Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP', {recursive: false}, (err, res) => { expect(err).to.not.exist expect(res.Pinned[0]).to.be.equal('Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP') @@ -9,7 +9,7 @@ describe('.pin', () => { }) }) - it('.pin.list', done => { + it('.pin.list', (done) => { apiClients['b'].pin.list((err, res) => { expect(err).to.not.exist expect(res).to.exist @@ -17,7 +17,7 @@ describe('.pin', () => { }) }) - it('.pin.remove', done => { + it('.pin.remove', (done) => { apiClients['b'].pin.remove('Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP', {recursive: false}, (err, res) => { expect(err).to.not.exist expect(res).to.exist @@ -34,14 +34,14 @@ describe('.pin', () => { it('.pin.add', () => { return apiClients['b'].pin .add('Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP', {recursive: false}) - .then(res => { + .then((res) => { expect(res.Pinned[0]).to.be.equal('Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP') }) }) it('.pin.list', () => { return apiClients['b'].pin.list() - .then(res => { + .then((res) => { expect(res).to.exist }) }) @@ -49,11 +49,11 @@ describe('.pin', () => { it('.pin.remove', () => { return apiClients['b'].pin .remove('Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP', {recursive: false}) - .then(res => { + .then((res) => { expect(res).to.exist return apiClients['b'].pin.list('direct') }) - .then(res => { + .then((res) => { expect(res).to.exist expect(res.Keys).to.be.empty }) diff --git a/test/api/ping.spec.js b/test/api/ping.spec.js index 6d409216b..b65f9d5b6 100644 --- a/test/api/ping.spec.js +++ b/test/api/ping.spec.js @@ -1,7 +1,7 @@ 'use strict' describe('.ping', () => { - it('ping another peer', done => { + it('ping another peer', (done) => { apiClients['b'].id((err, id) => { expect(err).to.not.exist @@ -16,10 +16,10 @@ describe('.ping', () => { describe('promise', () => { it('ping another peer', () => { return apiClients['b'].id() - .then(id => { + .then((id) => { return apiClients['a'].ping(id.ID) }) - .then(res => { + .then((res) => { expect(res).to.have.a.property('Success') }) }) diff --git a/test/api/refs.spec.js b/test/api/refs.spec.js index 07ad6276c..f08bd18e9 100644 --- a/test/api/refs.spec.js +++ b/test/api/refs.spec.js @@ -25,7 +25,7 @@ describe('.refs', () => { Err: '' }] - it('refs', done => { + it('refs', (done) => { if (!isNode) { return done() } @@ -44,7 +44,7 @@ describe('.refs', () => { if (!isNode) return return apiClients['a'].refs(folder, {'format': ' '}) - .then(objs => { + .then((objs) => { expect(objs).to.eql(result) }) }) diff --git a/test/api/swarm.spec.js b/test/api/swarm.spec.js index ea5595e42..2fa81aafc 100644 --- a/test/api/swarm.spec.js +++ b/test/api/swarm.spec.js @@ -1,7 +1,7 @@ 'use strict' describe('.swarm', () => { - it('.swarm.peers', done => { + it('.swarm.peers', (done) => { apiClients['a'].swarm.peers((err, res) => { expect(err).to.not.exist @@ -10,7 +10,7 @@ describe('.swarm', () => { }) }) - it('.swarm.connect', done => { + it('.swarm.connect', (done) => { // Done in the 'before' segment done() }) @@ -18,7 +18,7 @@ describe('.swarm', () => { describe('promise', () => { it('.swarm.peers', () => { return apiClients['a'].swarm.peers() - .then(res => { + .then((res) => { expect(res.Strings).to.have.length.above(1) }) }) diff --git a/test/api/version.spec.js b/test/api/version.spec.js index 34f688a65..3449f6f0e 100644 --- a/test/api/version.spec.js +++ b/test/api/version.spec.js @@ -3,7 +3,7 @@ describe('.version', () => { // note, IPFS HTTP-API returns always the same object, the filtering // happens on the CLI - it('checks the version', done => { + it('checks the version', (done) => { apiClients['a'].version((err, res) => { expect(err).to.not.exist expect(res).to.have.a.property('Version') @@ -13,7 +13,7 @@ describe('.version', () => { }) }) - it('with number option', done => { + it('with number option', (done) => { apiClients['a'].version({number: true}, (err, res) => { expect(err).to.not.exist expect(res).to.have.a.property('Version') @@ -23,7 +23,7 @@ describe('.version', () => { }) }) - it('with commit option', done => { + it('with commit option', (done) => { apiClients['a'].version({commit: true}, (err, res) => { expect(err).to.not.exist expect(res).to.have.a.property('Version') @@ -33,7 +33,7 @@ describe('.version', () => { }) }) - it('with repo option', done => { + it('with repo option', (done) => { apiClients['a'].version({commit: true}, (err, res) => { expect(err).to.not.exist expect(res).to.have.a.property('Version') @@ -46,7 +46,7 @@ describe('.version', () => { describe('promise', () => { it('checks the version', () => { return apiClients['a'].version() - .then(res => { + .then((res) => { expect(res).to.have.a.property('Version') expect(res).to.have.a.property('Commit') expect(res).to.have.a.property('Repo') @@ -55,7 +55,7 @@ describe('.version', () => { it('with number option', () => { return apiClients['a'].version({number: true}) - .then(res => { + .then((res) => { expect(res).to.have.a.property('Version') expect(res).to.have.a.property('Commit') expect(res).to.have.a.property('Repo') diff --git a/test/setup.js b/test/setup.js index 81ad12929..38bec0952 100644 --- a/test/setup.js +++ b/test/setup.js @@ -36,7 +36,7 @@ function connectNodes (done) { if (err) { throw err } - apiClients['a'].swarm.connect(addrs['c'], err => { + apiClients['a'].swarm.connect(addrs['c'], (err) => { if (err) { throw err } @@ -49,7 +49,7 @@ function connectNodes (done) { before(function (done) { this.timeout(20000) - Object.keys(apiAddrs).forEach(key => { + Object.keys(apiAddrs).forEach((key) => { global.apiClients[key] = ipfsAPI(apiAddrs[key]) })