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

refactor: convert version API to async/await #2679

Merged
merged 1 commit into from
Dec 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/core/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ exports.config = require('./config')
exports.init = require('./init')
exports.start = require('./start')
exports.stop = require('./stop')
exports.version = require('./version')

exports.legacy = { // TODO: these will be removed as the new API is completed
dag: require('./dag'),
Expand Down
3 changes: 2 additions & 1 deletion src/core/components/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,8 @@ function createApi ({
add,
config: Commands.config({ repo }),
init: () => { throw new AlreadyInitializedError() },
start
start,
version: Commands.version({ repo })
}

return api
Expand Down
3 changes: 2 additions & 1 deletion src/core/components/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ function createApi ({
config: Commands.config({ repo }),
init: () => { throw new AlreadyInitializedError() },
start: () => apiManager.api,
stop
stop,
version: Commands.version({ repo })
}

return api
Expand Down
3 changes: 2 additions & 1 deletion src/core/components/stop.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ function createApi ({
config: Commands.config({ repo }),
init: () => { throw new AlreadyInitializedError() },
start,
stop: () => apiManager.api
stop: () => apiManager.api,
version: Commands.version({ repo })
}

return api
Expand Down
9 changes: 4 additions & 5 deletions src/core/components/version.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
'use strict'

const pkg = require('../../../package.json')
const callbackify = require('callbackify')

// TODO add the commit hash of the current ipfs version to the response.
module.exports = function version (self) {
return callbackify(async () => {
const repoVersion = await self.repo.version()
module.exports = ({ repo }) => {
return async function version () {
const repoVersion = await repo.version()

return {
version: pkg.version,
repo: repoVersion,
commit: ''
}
})
}
}