Skip to content
This repository has been archived by the owner on Mar 18, 2024. It is now read-only.

Display Error message while unable to fetch type of package #439

Merged
merged 5 commits into from
Mar 16, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 17 additions & 37 deletions packages/core/src/sfdxwrappers/PackageVersionListImpl.ts
Original file line number Diff line number Diff line change
@@ -1,46 +1,26 @@
import child_process = require("child_process");
import SFPLogger from "../utils/SFPLogger";
import { onExit } from "../utils/OnExit";
import { SFDXCommand } from "../SFDXCommand";
import { LoggerLevel } from "../utils/SFPLogger";

export default class PackageVersionListImpl {
public constructor(private project_directory:string,private devhub_alias: string) {}

public async exec(): Promise<any> {
export default class PackageVersionListImpl extends SFDXCommand
{

let command = this.buildExecCommand();
SFPLogger.log("Executing command",command);
let child = child_process.exec(
command,
{ cwd: this.project_directory, encoding: "utf8" }
);

child.stderr.on("data", data => {
SFPLogger.log(data);
});

let output="";
child.stdout.on("data", data => {
output+=data;
});

await onExit(child);
public constructor(
devhub: string
) {
super(devhub, null);
}

let result = JSON.parse(output);
if(result.status==0)
{
public async exec(quiet?: boolean): Promise<any> {
let result =JSON.parse( await super.exec(quiet));
return result.result;
}
else
{
throw new Error("Unable to fetch Package Info");
}


}

private buildExecCommand(): string {
let command = `npx sfdx force:package:list -v ${this.devhub_alias} --json`;

return command;
getCommandName(): string {
return "PackageVersionList"
}
getGeneratedSFDXCommandWithParams(): string {
return `sfdx force:package:list --json -v ${this.target_org} `;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,6 @@ export default class CreateUnlockedPackageImpl {
private async getPackageTypeInfos() {
if (CreateUnlockedPackageImpl.packageTypeInfos == null) {
CreateUnlockedPackageImpl.packageTypeInfos = await new PackageVersionListImpl(
this.project_directory,
this.devhub_alias
).exec();
}
Expand Down