Skip to content

Commit 116ebbf

Browse 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
1 parent 917af12 commit 116ebbf

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

packages/schematics/angular/application/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

packages/schematics/angular/application/index_spec.ts

Lines 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)