Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(@angular/cli): improve error logging when resolving update migrations #20033

Merged
merged 1 commit into from Feb 11, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 28 additions & 1 deletion packages/angular/cli/commands/update-impl.ts
Expand Up @@ -284,6 +284,12 @@ export class UpdateCommand extends Command<UpdateCommandSchema> {
);
}

const logVerbose = (message: string) => {
if (options.verbose) {
this.logger.info(message);
}
};

if (options.all) {
const updateCmd = this.packageManager === PackageManager.Yarn
? `'yarn upgrade-interactive' or 'yarn upgrade'`
Expand Down Expand Up @@ -654,7 +660,28 @@ export class UpdateCommand extends Command<UpdateCommandSchema> {
for (const migration of migrations) {
// Resolve the package from the workspace root, as otherwise it will be resolved from the temp
// installed CLI version.
const packagePath = require.resolve(migration.package, { paths: [this.context.root] });
let packagePath;
logVerbose(
`Resolving migration package '${migration.package}' from '${this.context.root}'...`,
);
try {
packagePath = require.resolve(migration.package, { paths: [this.context.root] });
} catch (e) {
if (e.code === 'MODULE_NOT_FOUND') {
logVerbose(e.toString());
this.logger.error(
`Migrations for package (${migration.package}) were not found.` +
' The package could not be found in the workspace.',
);
} else {
this.logger.error(
`Unable to resolve migrations for package (${migration.package}). [${e.message}]`,
);
}

return 1;
}

let migrations;

// Check if it is a package-local location
Expand Down