Skip to content

Commit

Permalink
fix(help): use proper full command/namespace name, not alias
Browse files Browse the repository at this point in the history
  • Loading branch information
imhoffd committed Feb 2, 2020
1 parent 6f32ebc commit e42efc6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/@ionic/cli-framework/src/lib/__tests__/help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ describe('@ionic/cli-framework', () => {

it('should format a command appropriately', async () => {
const myns = new MyNamespace();
const location = await myns.locate(['foo', 'bar']);
const location = await myns.locate(['foo', 'b']);
const formatter = new CommandStringHelpFormatter({ location, command: location.obj as any });
const result = await formatter.format();

Expand Down Expand Up @@ -193,7 +193,7 @@ describe('@ionic/cli-framework', () => {

it('should format a subnamespace appropriately', async () => {
const myns = new MyNamespace();
const location = await myns.locate(['foo']);
const location = await myns.locate(['f']);
const formatter = new NamespaceStringHelpFormatter({ location, namespace: location.obj as any });
const result = await formatter.format();

Expand Down
18 changes: 16 additions & 2 deletions packages/@ionic/cli-framework/src/lib/help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,14 @@ export abstract class NamespaceHelpFormatter<C extends ICommand<C, N, M, I, O>,

async getNamespaceFullName(): Promise<string> {
if (!this._fullName) {
this._fullName = this.location.path.map(([p]) => p).join(' ');
const parts = await map(
this.location.path.slice(0, this.location.path.length - 1),
async ([, cmd]) => (await cmd.getMetadata()).name
);

const name = (await this.getNamespaceMetadata()).name;

this._fullName = [...parts, name].join(' ');
}

return this._fullName;
Expand Down Expand Up @@ -406,7 +413,14 @@ export abstract class CommandHelpFormatter<C extends ICommand<C, N, M, I, O>, N

async getCommandFullName(): Promise<string> {
if (!this._fullName) {
this._fullName = this.location.path.map(([p]) => p).join(' ');
const parts = await map(
this.location.path.slice(0, this.location.path.length - 1),
async ([, cmd]) => (await cmd.getMetadata()).name
);

const name = (await this.getCommandMetadata()).name;

this._fullName = [...parts, name].join(' ');
}

return this._fullName;
Expand Down

0 comments on commit e42efc6

Please sign in to comment.