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

Commit

Permalink
feat: display version info when starting daemon (#1915)
Browse files Browse the repository at this point in the history
Similar to what go-ipfs is now doing this prints the js-ipfs version, system arch/platform and Node.js version when a daemon is started.

Repo version is not yet included (but also unnecessary right now as we don't have repo migrations yet).

License: MIT
Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
  • Loading branch information
Alan Shaw authored Mar 11, 2019
1 parent 1fb3b6d commit 6b789ee
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/cli/commands/daemon.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict'

const os = require('os')
const { getRepoPath, print, ipfsPathHelp } = require('../utils')

module.exports = {
Expand Down Expand Up @@ -35,6 +36,9 @@ module.exports = {
handler (argv) {
argv.resolve((async () => {
print('Initializing IPFS daemon...')
print(`js-ipfs version: ${require('../../../package.json').version}`)
print(`System version: ${os.arch()}/${os.platform()}`)
print(`Node.js version: ${process.versions.node}`)

const repoPath = getRepoPath()

Expand Down
23 changes: 23 additions & 0 deletions test/cli/daemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const os = require('os')
const path = require('path')
const hat = require('hat')
const fs = require('fs')
const pkg = require('../../package.json')

const skipOnWindows = isWindows() ? it.skip : it

Expand Down Expand Up @@ -209,4 +210,26 @@ describe('daemon', () => {
done()
})
})

it('should print version info', async () => {
await ipfs('init')

const out = await new Promise(resolve => {
const res = ipfs('daemon')
let out = ''

res.stdout.on('data', function onData (data) {
out += data
if (out.includes('Daemon is ready')) {
res.stdout.removeListener('data', onData)
res.kill()
resolve(out)
}
})
})

expect(out).to.include(`js-ipfs version: ${pkg.version}`)
expect(out).to.include(`System version: ${os.arch()}/${os.platform()}`)
expect(out).to.include(`Node.js version: ${process.versions.node}`)
})
})

0 comments on commit 6b789ee

Please sign in to comment.