From 988de529dcefd7880b2c98ff65c4e220afa1e60f Mon Sep 17 00:00:00 2001 From: Jeff Dickey <216188+jdxcode@users.noreply.github.com> Date: Sat, 24 Mar 2018 11:28:40 -0700 Subject: [PATCH] feat: show version on root help --- src/root.ts | 1 + test/commands/help.test.ts | 6 +++++- test/root.test.ts | 6 +++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/root.ts b/src/root.ts index cfe00c61..227643fe 100644 --- a/src/root.ts +++ b/src/root.ts @@ -22,6 +22,7 @@ export default class RootHelp { let description = this.config.pjson.oclif.description || this.config.pjson.description || '' description = this.render(description) description = description.split('\n')[0] + description = `${this.config.userAgent}\n${description}` let output = compact([ description, this.usage(), diff --git a/test/commands/help.test.ts b/test/commands/help.test.ts index c5d39431..2a479a04 100644 --- a/test/commands/help.test.ts +++ b/test/commands/help.test.ts @@ -1,5 +1,8 @@ import {expect, test} from '@oclif/test' +const VERSION = require('../../package.json').version +const UA = `@oclif/plugin-help/${VERSION} ${process.platform}-${process.arch} node-${process.version}` + describe('help command', () => { test .stdout() @@ -47,7 +50,8 @@ OPTIONS .stdout() .command(['help']) .it('shows root help', ctx => { - expect(ctx.stdout).to.equal(`standard help for oclif + expect(ctx.stdout).to.equal(`${UA} +standard help for oclif USAGE $ oclif [COMMAND] diff --git a/test/root.test.ts b/test/root.test.ts index c5e2c71a..6c0ba35e 100644 --- a/test/root.test.ts +++ b/test/root.test.ts @@ -4,6 +4,9 @@ import stripAnsi = require('strip-ansi') global.columns = 80 import Help from '../src' +const VERSION = require('../package.json').version +const UA = `@oclif/plugin-help/${VERSION} ${process.platform}-${process.arch} node-${process.version}` + const test = base .loadConfig() .add('help', ctx => new Help(ctx.config)) @@ -21,7 +24,8 @@ const test = base describe('root help', () => { test .rootHelp() - .it(ctx => expect(ctx.commandHelp).to.equal(`standard help for oclif + .it(ctx => expect(ctx.commandHelp).to.equal(`${UA} +standard help for oclif USAGE $ oclif [COMMAND]`))