-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
feat(ng-add): respect project default style extension #12618
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,7 +41,11 @@ describe('material-install-schematic', () => { | |
'./node_modules/@angular/material/prebuilt-themes/indigo-pink.css'); | ||
}); | ||
|
||
it('should add custom theme', () => { | ||
it('should support adding a custom theme', () => { | ||
// TODO(devversion): currently a "custom" theme does only work for projects using SCSS. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does the CLI not support mixing scss with other preprocessors? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It does. The problem with the The schematic does not create a new scss file in a plain css project. It just looks for the default |
||
// TODO(devversion): Throw an error if a custom theme is being installed in a CSS project. | ||
appTree = createTestApp({style: 'scss'}); | ||
|
||
const tree = runner.runSchematic('ng-add', {theme: 'custom'}, appTree); | ||
|
||
const workspace = getWorkspace(tree); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* @license | ||
* Copyright Google LLC All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
|
||
import {WorkspaceProject} from '@schematics/angular/utility/config'; | ||
|
||
/** | ||
* Style extension that will be used if no default style extension for the CLI project | ||
* could be determined. | ||
*/ | ||
const fallbackStyleExtension = 'css'; | ||
|
||
/** | ||
* Determines the default style extension in the Angular CLI project by looking for the default | ||
* component schematic options. This is necessary for now because when creating CLI projects, | ||
* the CLI only makes the default `--style` option available for the `angular:component` schematic. | ||
*/ | ||
export function determineDefaultStyleExt(project: WorkspaceProject): string | null { | ||
if (project.schematics && | ||
project.schematics['@schematics/angular:component'] && | ||
project.schematics['@schematics/angular:component']['styleext']) { | ||
|
||
return project.schematics['@schematics/angular:component']['styleext']; | ||
} | ||
|
||
return fallbackStyleExtension; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small nit: prefer line breaking at the higher syntactic level
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense - I've started the wrap after the function name. That's what we do within other Jasmine tests as well (e.g.
expectTo(
) and that's also what CLang proposed me to do.