Skip to content

Commit

Permalink
fix: export the Version command and the VersionDetail interface. Enha…
Browse files Browse the repository at this point in the history
…nce the verbose details to include the shell and root path.
  • Loading branch information
Steve Hetzel committed Aug 17, 2022
1 parent 65f6220 commit fcf6aaf
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
12 changes: 11 additions & 1 deletion src/commands/version.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import {Command, Flags} from '@oclif/core'
import {EOL, type as osType, release as osRelease} from 'node:os'

interface VersionDetail {
export interface VersionDetail {
cliVersion: string;
architecture: string;
nodeVersion: string;
pluginVersions?: string[];
osVersion?: string;
shell?: string;
rootPath?: string;
}

export default class Version extends Command {
Expand Down Expand Up @@ -39,6 +41,8 @@ export default class Version extends Command {

versionDetail.pluginVersions = pluginVersions
versionDetail.osVersion = osVersion
versionDetail.shell = this.config.shell;
versionDetail.rootPath = this.config.root;

output = ` CLI Version:
\t${cliVersion}
Expand All @@ -54,6 +58,12 @@ export default class Version extends Command {
OS and Version:
\t${osVersion}
Shell:
\t${versionDetail.shell}
Root Path:
\t${versionDetail.rootPath}
`
}

Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export default {}
export { VersionDetail, default } from './commands/version';
13 changes: 12 additions & 1 deletion test/commands/version.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import {expect, test} from '@oclif/test'
import {type as osType, release as osRelease} from 'node:os'
import {type as osType, release as osRelease, userInfo as osUserInfo} from 'node:os'
import {sep} from 'path';

// eslint-disable-next-line unicorn/prefer-module
const pjson = require('../../package.json')

const getShell = () => osUserInfo().shell?.split(sep)?.pop();

describe('version', () => {
const stdout = `@oclif/plugin-version/${pjson.version} ${process.platform}-${process.arch} node-${process.version}
`
Expand Down Expand Up @@ -34,6 +37,12 @@ describe('version', () => {
OS and Version:
\t${osType()} ${osRelease()}
Shell:
\t${getShell()}
Root Path:
\t${process.cwd()}
`)
})

Expand All @@ -58,6 +67,8 @@ describe('version', () => {
nodeVersion: `node-${process.version}`,
osVersion: `${osType()} ${osRelease()}`,
pluginVersions: [],
shell: getShell(),
rootPath: process.cwd()
})
})
})

0 comments on commit fcf6aaf

Please sign in to comment.