Skip to content

Commit

Permalink
feat: add binAliases property to Config (#632)
Browse files Browse the repository at this point in the history
Co-authored-by: Mike Donnalley <mdonnalley@salesforce.com>
  • Loading branch information
WillieRuemmele and mdonnalley committed Feb 21, 2023
1 parent 93aae22 commit 9384f6e
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
/tmp
/test/tmp
.DS_Store
.idea
4 changes: 3 additions & 1 deletion src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -92,6 +92,7 @@ export class Config implements IConfig {
public valid!: boolean
public version!: string
public windows!: boolean
public binAliases?: string[];

protected warned = false

Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/interfaces/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: ':' | ' ';
Expand Down
1 change: 1 addition & 0 deletions src/interfaces/pjson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export namespace PJSON {
oclif: Plugin['oclif'] & {
schema?: number;
bin?: string;
binAliases?: string[];
npmRegistry?: string;
scope?: string;
dirname?: string;
Expand Down
11 changes: 9 additions & 2 deletions test/config/config.test.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -23,6 +22,7 @@ const pjson = {
files: [],
commands: {},
oclif: {
binAliases: ['foo', 'bar'],
topics: {
t1: {
description: 'desc for t1',
Expand Down Expand Up @@ -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'))
Expand Down

0 comments on commit 9384f6e

Please sign in to comment.