Repository: oclif/core
Pull request #259 (2021-09-27 14:16:09)

fix: adjust help text to new style guide
@W-9928119@


Patch:
diff --git a/src/config/plugin.ts b/src/config/plugin.ts
index 642fa0b..73b5828 100644
--- a/src/config/plugin.ts
+++ b/src/config/plugin.ts
@@ -135,11 +135,7 @@ export class Plugin implements IPlugin {
     this.manifest = await this._manifest(Boolean(this.options.ignoreManifest), Boolean(this.options.errorOnManifestCreate))
     this.commands = Object.entries(this.manifest.commands)
     .map(([id, c]) => ({...c, pluginAlias: this.alias, pluginType: this.type, load: async () => this.findCommand(id, {must: true})}))
-    this.commands.sort((a, b) => {
-      if (a.id < b.id) return -1
-      if (a.id > b.id) return 1
-      return 0
-    })
+    this.commands.sort((a, b) => a.id.localeCompare(b.id))
   }
 
   get topics(): Topic[] {
diff --git a/src/flags.ts b/src/flags.ts
index 47863a2..4b96cfd 100644
--- a/src/flags.ts
+++ b/src/flags.ts
@@ -31,7 +31,7 @@ export {boolean, integer, url} from './parser'
 
 export const version = (opts: Partial<BooleanFlag<boolean>> = {}) => {
   return Parser.flags.boolean({
-    description: 'show CLI version',
+    description: 'Show CLI version.',
     ...opts,
     parse: async (_: any, cmd: Command) => {
       cmd.log(cmd.config.userAgent)
@@ -42,7 +42,7 @@ export const version = (opts: Partial<BooleanFlag<boolean>> = {}) => {
 
 export const help = (opts: Partial<BooleanFlag<boolean>> = {}) => {
   return Parser.flags.boolean({
-    description: 'show CLI help',
+    description: 'Show CLI help.',
     ...opts,
     parse: async (_: any, cmd: Command) => {
       (cmd as any)._help()
diff --git a/src/help/index.ts b/src/help/index.ts
index 7739d93..cde4e19 100644
--- a/src/help/index.ts
+++ b/src/help/index.ts
@@ -116,7 +116,7 @@ export class Help extends HelpBase {
       return
     }
 
-    error(`command ${subject} not found`)
+    error(`Command ${subject} not found.`)
   }
 
   public async showCommandHelp(command: Interfaces.Command) {
diff --git a/src/main.ts b/src/main.ts
index 8556776..23eaa5e 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -3,6 +3,7 @@ import {fileURLToPath} from 'url'
 import {format, inspect} from 'util'
 
 import * as Interfaces from './interfaces'
+import {URL} from 'url'
 import {Config} from './config'
 import {getHelpFlagAdditions, loadHelpClass, standardizeIDFromArgv} from './help'
 
@@ -33,7 +34,7 @@ export const versionAddition = (argv: string[], config?: Interfaces.Config): boo
 // eslint-disable-next-line default-param-last
 export async function run(argv = process.argv.slice(2), options?: Interfaces.LoadOptions) {
   // Handle the case when a file URL string or URL is passed in such as 'import.meta.url'; covert to file path.
-  if ((typeof options === 'string' && options.startsWith('file://')) || options instanceof URL) {
+  if (options && ((typeof options === 'string' && options.startsWith('file://')) || options instanceof URL)) {
     options = fileURLToPath(options)
   }
 
diff --git a/tsconfig.json b/tsconfig.json
index c8a673e..24c61a7 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -9,7 +9,8 @@
       "./src"
     ],
     "strict": true,
-    "target": "es2017"
+    "target": "es2019",
+    "lib": ["es2019"]
   },
   "include": [
     "./src/**/*"


Test patch:
diff --git a/test/help/show-help.test.ts b/test/help/show-help.test.ts
index 701274a..bc572cb 100644
--- a/test/help/show-help.test.ts
+++ b/test/help/show-help.test.ts
@@ -360,7 +360,7 @@ describe('showHelp routing', () => {
     test
     .setupHelp()
     .it('shows an error when there is a subject but it does not match a topic or command', async ({help}) => {
-      await expect(help.showHelp(['meow'])).to.be.rejectedWith('command meow not found')
+      await expect(help.showHelp(['meow'])).to.be.rejectedWith('Command meow not found')
     })
   })
 })
diff --git a/test/parser/parse.test.ts b/test/parser/parse.test.ts
index 993aba1..5bea4f4 100644
--- a/test/parser/parse.test.ts
+++ b/test/parser/parse.test.ts
@@ -3,6 +3,8 @@ import {expect} from 'chai'
 
 import {flags, parse} from '../../src/parser'
 import {Interfaces} from '../../src'
+import {URL} from 'url'
+
 const stripAnsi = require('strip-ansi')
 
 describe('parse', () => {