Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
engine-strict=true
2 changes: 2 additions & 0 deletions packages/schematics/angular/workspace/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ export default function (options: WorkspaceOptions): Rule {
return mergeWith(
apply(url('./files'), [
options.minimal ? filter((path) => !path.endsWith('editorconfig.template')) : noop(),
// Unlike other package managers, npm only warns about unsupported `engines` by default.
packageManager !== 'npm' ? filter((path) => !path.endsWith('npmrc.template')) : noop(),
applyTemplates({
utils: strings,
...options,
Expand Down
18 changes: 18 additions & 0 deletions packages/schematics/angular/workspace/index_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,24 @@ describe('Workspace Schematic', () => {
);
});

it('should enable npm `engine-strict` in .npmrc when using npm', async () => {
const tree = await schematicRunner.runSchematic('workspace', {
...defaultOptions,
packageManager: 'npm',
});
expect(tree.readContent('/.npmrc')).toBe('engine-strict=true\n');
});

for (const packageManager of ['yarn', 'pnpm', 'bun', undefined] as const) {
it(`should not create an .npmrc when the package manager is ${packageManager}`, async () => {
const tree = await schematicRunner.runSchematic('workspace', {
...defaultOptions,
packageManager,
});
expect(tree.exists('/.npmrc')).toBeFalse();
});
}

it('should set the name in package.json', async () => {
const tree = await schematicRunner.runSchematic('workspace', defaultOptions);
const pkg = JSON.parse(tree.readContent('/package.json'));
Expand Down
Loading