Skip to content

Commit 28d9d78

Browse files
authored
fix: adjust help text to new style guide (#259)
* fix: fix: adjust help text to new style guide @W-9928119@ * chore: fix broken unit test
1 parent c62f584 commit 28d9d78

File tree

7 files changed

+11
-11
lines changed

7 files changed

+11
-11
lines changed

src/config/plugin.ts

+1-5
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,7 @@ export class Plugin implements IPlugin {
135135
this.manifest = await this._manifest(Boolean(this.options.ignoreManifest), Boolean(this.options.errorOnManifestCreate))
136136
this.commands = Object.entries(this.manifest.commands)
137137
.map(([id, c]) => ({...c, pluginAlias: this.alias, pluginType: this.type, load: async () => this.findCommand(id, {must: true})}))
138-
this.commands.sort((a, b) => {
139-
if (a.id < b.id) return -1
140-
if (a.id > b.id) return 1
141-
return 0
142-
})
138+
this.commands.sort((a, b) => a.id.localeCompare(b.id))
143139
}
144140

145141
get topics(): Topic[] {

src/flags.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export {boolean, integer, url} from './parser'
3131

3232
export const version = (opts: Partial<BooleanFlag<boolean>> = {}) => {
3333
return Parser.flags.boolean({
34-
description: 'show CLI version',
34+
description: 'Show CLI version.',
3535
...opts,
3636
parse: async (_: any, cmd: Command) => {
3737
cmd.log(cmd.config.userAgent)
@@ -42,7 +42,7 @@ export const version = (opts: Partial<BooleanFlag<boolean>> = {}) => {
4242

4343
export const help = (opts: Partial<BooleanFlag<boolean>> = {}) => {
4444
return Parser.flags.boolean({
45-
description: 'show CLI help',
45+
description: 'Show CLI help.',
4646
...opts,
4747
parse: async (_: any, cmd: Command) => {
4848
(cmd as any)._help()

src/help/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export class Help extends HelpBase {
116116
return
117117
}
118118

119-
error(`command ${subject} not found`)
119+
error(`Command ${subject} not found.`)
120120
}
121121

122122
public async showCommandHelp(command: Interfaces.Command) {

src/main.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {fileURLToPath} from 'url'
33
import {format, inspect} from 'util'
44

55
import * as Interfaces from './interfaces'
6+
import {URL} from 'url'
67
import {Config} from './config'
78
import {getHelpFlagAdditions, loadHelpClass, standardizeIDFromArgv} from './help'
89

@@ -33,7 +34,7 @@ export const versionAddition = (argv: string[], config?: Interfaces.Config): boo
3334
// eslint-disable-next-line default-param-last
3435
export async function run(argv = process.argv.slice(2), options?: Interfaces.LoadOptions) {
3536
// Handle the case when a file URL string or URL is passed in such as 'import.meta.url'; covert to file path.
36-
if ((typeof options === 'string' && options.startsWith('file://')) || options instanceof URL) {
37+
if (options && ((typeof options === 'string' && options.startsWith('file://')) || options instanceof URL)) {
3738
options = fileURLToPath(options)
3839
}
3940

test/help/show-help.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ describe('showHelp routing', () => {
360360
test
361361
.setupHelp()
362362
.it('shows an error when there is a subject but it does not match a topic or command', async ({help}) => {
363-
await expect(help.showHelp(['meow'])).to.be.rejectedWith('command meow not found')
363+
await expect(help.showHelp(['meow'])).to.be.rejectedWith('Command meow not found')
364364
})
365365
})
366366
})

test/parser/parse.test.ts

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import {expect} from 'chai'
33

44
import {flags, parse} from '../../src/parser'
55
import {Interfaces} from '../../src'
6+
import {URL} from 'url'
7+
68
const stripAnsi = require('strip-ansi')
79

810
describe('parse', () => {

tsconfig.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"./src"
1010
],
1111
"strict": true,
12-
"target": "es2017"
12+
"target": "es2019",
13+
"lib": ["es2019"]
1314
},
1415
"include": [
1516
"./src/**/*"

0 commit comments

Comments
 (0)