Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit bf64a0f

Browse filesBrowse files
committed
fix(@schematics/angular): add less as a devDependency when selected as the style preprocessor
Ensure `less` is automatically added to `devDependencies` when users choose it as the style preprocessor during application generation. Closes #30503 (cherry picked from commit 42f45a3)
1 parent 424f1cb commit bf64a0f
Copy full SHA for bf64a0f

File tree

Expand file treeCollapse file tree

2 files changed

+25
-7
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+25
-7
lines changed

‎packages/schematics/angular/application/index.ts

Copy file name to clipboardExpand all lines: packages/schematics/angular/application/index.ts
+11-7Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ function addTsProjectReference(...paths: string[]) {
4949
}
5050

5151
export default function (options: ApplicationOptions): Rule {
52-
return async (host: Tree, context: SchematicContext) => {
52+
return async (host: Tree) => {
5353
const { appDir, appRootSelector, componentOptions, folderName, sourceDir } =
5454
await getAppOptions(host, options);
5555

5656
return chain([
57-
addAppToWorkspaceFile(options, appDir, folderName),
57+
addAppToWorkspaceFile(options, appDir),
5858
addTsProjectReference('./' + join(normalize(appDir), 'tsconfig.app.json')),
5959
options.skipTests || options.minimal
6060
? noop()
@@ -157,6 +157,14 @@ function addDependenciesToPackageJson(options: ApplicationOptions) {
157157
});
158158
}
159159

160+
if (options.style === Style.Less) {
161+
addPackageJsonDependency(host, {
162+
type: NodeDependencyType.Dev,
163+
name: 'less',
164+
version: latestVersions['less'],
165+
});
166+
}
167+
160168
if (!options.skipInstall) {
161169
context.addTask(new NodePackageInstallTask());
162170
}
@@ -165,11 +173,7 @@ function addDependenciesToPackageJson(options: ApplicationOptions) {
165173
};
166174
}
167175

168-
function addAppToWorkspaceFile(
169-
options: ApplicationOptions,
170-
appDir: string,
171-
folderName: string,
172-
): Rule {
176+
function addAppToWorkspaceFile(options: ApplicationOptions, appDir: string): Rule {
173177
let projectRoot = appDir;
174178
if (projectRoot) {
175179
projectRoot += '/';

‎packages/schematics/angular/application/index_spec.ts

Copy file name to clipboardExpand all lines: packages/schematics/angular/application/index_spec.ts
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,20 @@ describe('Application Schematic', () => {
282282
expect(pkg.dependencies['zone.js']).toEqual(latestVersions['zone.js']);
283283
});
284284

285+
it('should add "less" to devDependencies when Less is selected as the style option', async () => {
286+
const tree = await schematicRunner.runSchematic(
287+
'application',
288+
{
289+
...defaultOptions,
290+
style: Style.Less,
291+
},
292+
workspaceTree,
293+
);
294+
295+
const pkg = JSON.parse(tree.readContent('/package.json'));
296+
expect(pkg.devDependencies['less']).toEqual(latestVersions['less']);
297+
});
298+
285299
it('should include zone.js if "zoneless" option is not present', async () => {
286300
const tree = await schematicRunner.runSchematic(
287301
'application',

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.