From 70876e3edb2f2a5169a29e2ede011608fac81bc0 Mon Sep 17 00:00:00 2001 From: Willie Ruemmele Date: Thu, 18 Feb 2021 08:44:51 -0700 Subject: [PATCH] fix: fix sorting logic --- src/commands/force/source/deploy.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/commands/force/source/deploy.ts b/src/commands/force/source/deploy.ts index 87d09aca9..c37d94386 100644 --- a/src/commands/force/source/deploy.ts +++ b/src/commands/force/source/deploy.ts @@ -126,13 +126,13 @@ export class deploy extends SourceCommand { private printComponentFailures(result: SourceDeployResult): void { if (result.status === 'Failed' && result.components) { // sort by filename then fullname - const failures = result.components - .sort((i, j) => { - return i.component.type.directoryName < j.component.type.directoryName ? -1 : 1; - }) - .sort((i, j) => { - return i.component.fullName < j.component.fullName ? -1 : 1; - }); + const failures = result.components.sort((i, j) => { + if (i.component.type.directoryName === j.component.type.directoryName) { + // if the have the same directoryName then sort by fullName + return i.component.fullName < j.component.fullName ? 1 : -1; + } + return i.component.type.directoryName < j.component.type.directoryName ? 1 : -1; + }); this.ux.log(''); this.ux.styledHeader(chalk.red(`Component Failures [${failures.length}]`)); this.ux.table(failures, { @@ -157,14 +157,14 @@ export class deploy extends SourceCommand { // same metadata type, according to above comment sort on filename if (i.component.type.directoryName === j.component.type.directoryName) { // same filename's according to comment sort by fullName - return i.component.fullName < j.component.fullName ? -1 : 1; + return i.component.fullName < j.component.fullName ? 1 : -1; } - return i.component.type.directoryName < j.component.type.directoryName ? -1 : 1; + return i.component.type.directoryName < j.component.type.directoryName ? 1 : -1; } - return i.component.type.name < j.component.type.name ? -1 : 1; + return i.component.type.name < j.component.type.name ? 1 : -1; }); // get relative path for table output - files.map((file) => { + files.forEach((file) => { if (file.component.content) { return (file.component.content = path.relative(process.cwd(), file.component.content)); }