diff --git a/integration/mdc-migration/golden/src/broken.css b/integration/mdc-migration/golden/src/broken.css new file mode 100644 index 000000000000..0fd1c6dde9ca --- /dev/null +++ b/integration/mdc-migration/golden/src/broken.css @@ -0,0 +1,5 @@ +/* Does not compile (missing semicolons) */ +.mat-button { + width: 100 + height: 100 +} diff --git a/integration/mdc-migration/golden/src/dont-migrate-me.css.skip b/integration/mdc-migration/golden/src/dont-migrate-me.css.skip new file mode 100644 index 000000000000..fe4cfdd8c542 --- /dev/null +++ b/integration/mdc-migration/golden/src/dont-migrate-me.css.skip @@ -0,0 +1,4 @@ +/* Should not be migrated (filename is not .css or .scss) */ +.mat-button { + width: 100px; +} diff --git a/integration/mdc-migration/sample-project/src/broken.css b/integration/mdc-migration/sample-project/src/broken.css new file mode 100644 index 000000000000..0fd1c6dde9ca --- /dev/null +++ b/integration/mdc-migration/sample-project/src/broken.css @@ -0,0 +1,5 @@ +/* Does not compile (missing semicolons) */ +.mat-button { + width: 100 + height: 100 +} diff --git a/integration/mdc-migration/sample-project/src/dont-migrate-me.css.skip b/integration/mdc-migration/sample-project/src/dont-migrate-me.css.skip new file mode 100644 index 000000000000..fe4cfdd8c542 --- /dev/null +++ b/integration/mdc-migration/sample-project/src/dont-migrate-me.css.skip @@ -0,0 +1,4 @@ +/* Should not be migrated (filename is not .css or .scss) */ +.mat-button { + width: 100px; +} diff --git a/src/cdk/schematics/ng-update/find-stylesheets.ts b/src/cdk/schematics/ng-update/find-stylesheets.ts index 13f7f651fe09..8702835f2f5d 100644 --- a/src/cdk/schematics/ng-update/find-stylesheets.ts +++ b/src/cdk/schematics/ng-update/find-stylesheets.ts @@ -10,7 +10,7 @@ import {join, Path} from '@angular-devkit/core'; import {Tree} from '@angular-devkit/schematics'; /** Regular expression that matches stylesheet paths */ -const STYLESHEET_REGEX = /.*\.(css|scss)/; +const STYLESHEET_REGEX = /.*\.(css|scss)$/; /** * Finds stylesheets in the given directory from within the specified tree. diff --git a/src/material/schematics/ng-generate/mdc-migration/BUILD.bazel b/src/material/schematics/ng-generate/mdc-migration/BUILD.bazel index beed7ee26cd0..581c49f575cc 100644 --- a/src/material/schematics/ng-generate/mdc-migration/BUILD.bazel +++ b/src/material/schematics/ng-generate/mdc-migration/BUILD.bazel @@ -91,6 +91,7 @@ jasmine_node_test( "//src/material/schematics:collection_assets", "//src/material/schematics:ng_generate_assets", ], + shard_count = 10, deps = [ ":unit_tests_bundle", # Runtime dependencies needed by the test and actual migration sources. These need diff --git a/src/material/schematics/ng-generate/mdc-migration/rules/theming-styles.ts b/src/material/schematics/ng-generate/mdc-migration/rules/theming-styles.ts index 65398700d5b7..74054ddba117 100644 --- a/src/material/schematics/ng-generate/mdc-migration/rules/theming-styles.ts +++ b/src/material/schematics/ng-generate/mdc-migration/rules/theming-styles.ts @@ -22,10 +22,10 @@ export class ThemingStylesMigration extends Migration { RootExit: root => this._handleRootNode(root, stylesheet.filePath, namespace), }, ]); - processor.process(stylesheet.content, {syntax: scss}).sync(); + try { + processor.process(stylesheet.content, {syntax: scss}).sync(); + } catch (e) { + this.logger.error(`${e}`); + this.logger.warn(`Failed to process stylesheet: ${stylesheet.filePath} (see error above).`); + } } /** Returns the namespace of the given at-rule if it is importing from @angular/material. */