diff --git a/src/repo/index.js b/src/repo/index.js index c70098d35..d3ac72785 100644 --- a/src/repo/index.js +++ b/src/repo/index.js @@ -7,6 +7,7 @@ module.exports = (arg) => { return { gc: require('./gc')(send), - stat: require('./stat')(send) + stat: require('./stat')(send), + version: require('./version')(send) } } diff --git a/src/repo/version.js b/src/repo/version.js new file mode 100644 index 000000000..0b49f78c6 --- /dev/null +++ b/src/repo/version.js @@ -0,0 +1,16 @@ +'use strict' + +const promisify = require('promisify-es6') + +module.exports = (send) => { + return promisify((opts, callback) => { + if (typeof (opts) === 'function') { + callback = opts + opts = {} + } + send({ + path: 'repo/version', + qs: opts + }, callback) + }) +} diff --git a/test/repo.spec.js b/test/repo.spec.js index 0af2a0001..df4b4be75 100644 --- a/test/repo.spec.js +++ b/test/repo.spec.js @@ -44,6 +44,15 @@ describe('.repo', function () { done() }) }) + + it('.repo.version', (done) => { + ipfs.repo.version((err, res) => { + expect(err).to.not.exist() + expect(res).to.exist() + expect(res).to.have.a.property('Version') + done() + }) + }) }) describe('Promise API', () => { @@ -59,5 +68,13 @@ describe('.repo', function () { expect(res).to.have.a.property('RepoSize') }) }) + + it('.repo.version', () => { + return ipfs.repo.version() + .then(res => { + expect(res).to.exist() + expect(res).to.have.a.property('Version') + }) + }) }) })