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,13 +107,23 @@ export class ListProfilesCommand implements ICommand<IListProfilesCommandOptions
.join(' ')} ${Array.from(fromSelectors)
.map((x) => `--from ${x}`)
.join(' ')} `;
const res: { projects: IProject[] } = JSON.parse(childProcess.execSync(rushListCmd).toString());
for (const project of res.projects) {
if (profileProjects.has(project.name)) {
const profiles: string[] | undefined = profileProjects.get(project.name);
profiles?.push(profileName);
} else {
profileProjects.set(project.name, [profileName]);
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) {
if (profileProjects.has(project.name)) {
const profiles: string[] | undefined = profileProjects.get(project.name);
profiles?.push(profileName);
} else {
profileProjects.set(project.name, [profileName]);
}
}
}
}