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

Commit 6b789ee

Browse files
author
Alan Shaw
authored
feat: display version info when starting daemon (#1915)
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>
1 parent 1fb3b6d commit 6b789ee

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

src/cli/commands/daemon.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use strict'
22

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

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

3943
const repoPath = getRepoPath()
4044

test/cli/daemon.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const os = require('os')
99
const path = require('path')
1010
const hat = require('hat')
1111
const fs = require('fs')
12+
const pkg = require('../../package.json')
1213

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

@@ -209,4 +210,26 @@ describe('daemon', () => {
209210
done()
210211
})
211212
})
213+
214+
it('should print version info', async () => {
215+
await ipfs('init')
216+
217+
const out = await new Promise(resolve => {
218+
const res = ipfs('daemon')
219+
let out = ''
220+
221+
res.stdout.on('data', function onData (data) {
222+
out += data
223+
if (out.includes('Daemon is ready')) {
224+
res.stdout.removeListener('data', onData)
225+
res.kill()
226+
resolve(out)
227+
}
228+
})
229+
})
230+
231+
expect(out).to.include(`js-ipfs version: ${pkg.version}`)
232+
expect(out).to.include(`System version: ${os.arch()}/${os.platform()}`)
233+
expect(out).to.include(`Node.js version: ${process.versions.node}`)
234+
})
212235
})

0 commit comments

Comments
 (0)