chore: improve logging

This commit is contained in:
Cheng Liu 2024-10-21 20:22:47 -07:00
parent f55b682f19
commit e379119283
No known key found for this signature in database
GPG key ID: BDD2FDCF5AC296BA

View file

@ -107,7 +107,16 @@ export class ListProfilesCommand implements ICommand<IListProfilesCommandOptions
.join(' ')} ${Array.from(fromSelectors) .join(' ')} ${Array.from(fromSelectors)
.map((x) => `--from ${x}`) .map((x) => `--from ${x}`)
.join(' ')} `; .join(' ')} `;
const res: { projects: IProject[] } = JSON.parse(childProcess.execSync(rushListCmd).toString()); let res: { projects: IProject[] } | undefined;
const resultString: string = childProcess.execSync(rushListCmd).toString();
try {
res = JSON.parse(resultString);
} catch (e) {
throw new Error(
`Parse json result from ${rushListCmd} failed.\nError: ${e.message}\nrush returns:\n${resultString}\n`
);
}
if (res) {
for (const project of res.projects) { for (const project of res.projects) {
if (profileProjects.has(project.name)) { if (profileProjects.has(project.name)) {
const profiles: string[] | undefined = profileProjects.get(project.name); const profiles: string[] | undefined = profileProjects.get(project.name);
@ -117,6 +126,7 @@ export class ListProfilesCommand implements ICommand<IListProfilesCommandOptions
} }
} }
} }
}
const profilesContainProject: string[] | undefined = profileProjects.get(project); const profilesContainProject: string[] | undefined = profileProjects.get(project);
if (profilesContainProject) { if (profilesContainProject) {