From 6b789ee2958f6d1b6340d9de9ded049f8a34ab2a Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Mon, 11 Mar 2019 18:15:59 +0000 Subject: [PATCH] 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 --- src/cli/commands/daemon.js | 4 ++++ test/cli/daemon.js | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/src/cli/commands/daemon.js b/src/cli/commands/daemon.js index 0377f92b96..8e254164bb 100644 --- a/src/cli/commands/daemon.js +++ b/src/cli/commands/daemon.js @@ -1,5 +1,6 @@ 'use strict' +const os = require('os') const { getRepoPath, print, ipfsPathHelp } = require('../utils') module.exports = { @@ -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() diff --git a/test/cli/daemon.js b/test/cli/daemon.js index 5e9efe08d8..afebfbbc41 100644 --- a/test/cli/daemon.js +++ b/test/cli/daemon.js @@ -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 @@ -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}`) + }) })