Repository: oclif/core
Pull request #632 (2023-02-17 16:51:17)

feat: add binAliases property to Config
@W-12545437@

add `binAliases` property to the `Config` type


Patch:
diff --git a/.gitignore b/.gitignore
index 54209a8..17dcdfa 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,3 +9,4 @@
 /tmp
 /test/tmp
 .DS_Store
+.idea
diff --git a/src/config/config.ts b/src/config/config.ts
index 865055a..2d46a1d 100644
--- a/src/config/config.ts
+++ b/src/config/config.ts
@@ -12,7 +12,7 @@ import * as Plugin from './plugin'
 import {Debug, compact, loadJSON, collectUsableIds, getCommandIdPermutations} from './util'
 import {ensureArgObject, isProd, requireJson} from '../util'
 import ModuleLoader from '../module-loader'
-import {getHelpFlagAdditions} from '../help/util'
+import {getHelpFlagAdditions} from '../help'
 import {Command} from '../command'
 import {CompletableOptionFlag, Arg} from '../interfaces/parser'
 import {stdout} from '../cli-ux/stream'
@@ -92,6 +92,7 @@ export class Config implements IConfig {
   public valid!: boolean
   public version!: string
   public windows!: boolean
+  public binAliases?: string[];
 
   protected warned = false
 
@@ -137,6 +138,7 @@ export class Config implements IConfig {
     this.platform = WSL ? 'wsl' : os.platform() as any
     this.windows = this.platform === 'win32'
     this.bin = this.pjson.oclif.bin || this.name
+    this.binAliases = this.pjson.oclif.binAliases
     this.dirname = this.pjson.oclif.dirname || this.name
     this.flexibleTaxonomy = this.pjson.oclif.flexibleTaxonomy || false
     // currently, only colons or spaces are valid separators
diff --git a/src/interfaces/config.ts b/src/interfaces/config.ts
index 62f4cef..a7ea990 100644
--- a/src/interfaces/config.ts
+++ b/src/interfaces/config.ts
@@ -87,6 +87,10 @@ export interface Config {
   userPJSON?: PJSON.User;
   plugins: Plugin[];
   binPath?: string;
+  /**
+   * name of any bin aliases that will execute the cli
+   */
+  binAliases?: string[];
   valid: boolean;
   flexibleTaxonomy?: boolean;
   topicSeparator: ':' | ' ';
diff --git a/src/interfaces/pjson.ts b/src/interfaces/pjson.ts
index bdcbd58..7560b13 100644
--- a/src/interfaces/pjson.ts
+++ b/src/interfaces/pjson.ts
@@ -77,6 +77,7 @@ export namespace PJSON {
     oclif: Plugin['oclif'] & {
       schema?: number;
       bin?: string;
+      binAliases?: string[];
       npmRegistry?: string;
       scope?: string;
       dirname?: string;


Test patch:
diff --git a/test/config/config.test.ts b/test/config/config.test.ts
index 015e1ae..43f7ee5 100644
--- a/test/config/config.test.ts
+++ b/test/config/config.test.ts
@@ -1,12 +1,11 @@
 import * as os from 'os'
 import * as path from 'path'
 
-import {Config} from '../../src/config/config'
 import {Plugin as IPlugin} from '../../src/interfaces'
 import * as util from '../../src/config/util'
 
 import {expect, fancy} from './test'
-import {Command, Interfaces} from '../../src'
+import {Command, Config, Interfaces} from '../../src'
 
 interface Options {
   pjson?: any;
@@ -23,6 +22,7 @@ const pjson = {
   files: [],
   commands: {},
   oclif: {
+    binAliases: ['foo', 'bar'],
     topics: {
       t1: {
         description: 'desc for t1',
@@ -100,6 +100,13 @@ describe('Config', () => {
     .hasProperty('home', path.join('/my/home'))
   })
 
+  describe('binAliases', () => {
+    testConfig({pjson})
+    .it('will have binAliases set', config => {
+      expect(config.binAliases).to.deep.equal(['foo', 'bar'])
+    })
+  })
+
   describe('linux', () => {
     testConfig({platform: 'linux'})
     .hasProperty('cacheDir', path.join('/my/home/.cache/@oclif/core'))