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) .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;
for (const project of res.projects) { const resultString: string = childProcess.execSync(rushListCmd).toString();
if (profileProjects.has(project.name)) { try {
const profiles: string[] | undefined = profileProjects.get(project.name); res = JSON.parse(resultString);
profiles?.push(profileName); } catch (e) {
} else { throw new Error(
profileProjects.set(project.name, [profileName]); `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]);
}
} }
} }
} }