Skip to content

Commit

Permalink
fix: unit tests & lint
Browse files Browse the repository at this point in the history
  • Loading branch information
RodEsp committed Jun 13, 2022
1 parent b47a1fd commit a7037af
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
24 changes: 12 additions & 12 deletions src/commands/version.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Command, Flags} from '@oclif/core'
import {type as osType, release as osRelease} from 'node:os'
import {EOL, type as osType, release as osRelease} from 'node:os'

export default class Version extends Command {
public static flags = {
Expand All @@ -11,29 +11,29 @@ export default class Version extends Command {

async run(): Promise<void> {
const {flags} = await this.parse(Version)
let output = `${this.config.userAgent} \n`
let output = `${this.config.userAgent}${EOL}`

if (flags.verbose) {
const versions = this.config.userAgent.split(' ')
const cliVersion: string = versions[0]
const architecture: string = versions[1]
const nodeVersion: string = versions[2]

const pluginVersions: string = this.config.plugins.reduce((accumulator, plugin) => {
accumulator += `\n\t${plugin.name}@${plugin.version} (${plugin.type})`
return accumulator
}, '')
let pluginVersions = ''
for (const plugin of this.config.plugins) {
pluginVersions += `${EOL}\t${plugin.name}@${plugin.version} (${plugin.type})`
}

const osVersion = `${osType()} ${osRelease()}`

output = ` CLI Version : \n\t${cliVersion}
\n Architecture: \n\t${architecture}
\n Node Version : \n\t${nodeVersion}
\n Plugin Version: ${pluginVersions}
\n OS and Version: \n\t${osVersion}
output = ` CLI Version : ${EOL}\t${cliVersion}
${EOL} Architecture: ${EOL}\t${architecture}
${EOL} Node Version : ${EOL}\t${nodeVersion}
${EOL} Plugin Version: ${pluginVersions}
${EOL} OS and Version: ${EOL}\t${osVersion}
`
}

this.log(output)
process.stdout.write(output)
}
}
3 changes: 2 additions & 1 deletion test/commands/version.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import {expect, test} from '@oclif/test'
import {EOL} from 'node:os'

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

describe('version', () => {
const stdout = `@oclif/plugin-version/${pjson.version} ${process.platform}-${process.arch} node-${process.version}\n`
const stdout = `@oclif/plugin-version/${pjson.version} ${process.platform}-${process.arch} node-${process.version}${EOL}`

test
.stdout()
Expand Down

0 comments on commit a7037af

Please sign in to comment.