Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
fix(version): better http-api and interface-ipfs-core compliant
Browse files Browse the repository at this point in the history
  • Loading branch information
dignifiedquire committed Sep 15, 2016
1 parent 2beac9c commit 0ee7215
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
6 changes: 1 addition & 5 deletions src/cli/commands/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,7 @@ module.exports = {
throw err
}

if (typeof version === 'object') { // js-ipfs-api output
version = version.Version
}

console.log(`js-ipfs version: ${version}`)
console.log(`js-ipfs version: ${version.version}`)
})
})
}
Expand Down
10 changes: 8 additions & 2 deletions src/http-api/resources/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,17 @@ const boom = require('boom')
exports = module.exports

exports.get = (request, reply) => {
request.server.app.ipfs.version((err, version) => {
const ipfs = request.server.app.ipfs

ipfs.version((err, version) => {
if (err) {
return reply(boom.badRequest(err))
}

reply(version)
reply({
Version: version.version,
Commit: version.commit,
Repo: version.repo
})
})
}
4 changes: 2 additions & 2 deletions test/cli/test-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('version', () => {
const env = _.clone(process.env)
env.IPFS_PATH = repoPath

describe.skip('api offline', () => {
describe('api offline', () => {
it('get the version', (done) => {
nexpect.spawn('node', [process.cwd() + '/src/cli/bin.js', 'version'], {env})
.run((err, stdout, exitcode) => {
Expand All @@ -24,7 +24,7 @@ describe('version', () => {
})
})

describe.skip('api running', () => {
describe('api running', () => {
let httpAPI

before((done) => {
Expand Down
6 changes: 3 additions & 3 deletions test/http-api/inject/test-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ module.exports = (http) => {
method: 'GET',
url: '/api/v0/version'
}, (res) => {
expect(res.result.version).to.equal(pkgversion)
expect(res.result).to.have.a.property('commit')
expect(res.result).to.have.a.property('repo')
expect(res.result).to.have.a.property('Version', pkgversion)
expect(res.result).to.have.a.property('Commit')
expect(res.result).to.have.a.property('Repo')
done()
})
})
Expand Down

0 comments on commit 0ee7215

Please sign in to comment.