Skip to content
Merged
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
7 changes: 1 addition & 6 deletions packages/angular_devkit/schematics/src/tree/host-tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import {
import { ParseError, parse as jsoncParse, printParseErrorCode } from 'jsonc-parser';
import {
ContentHasMutatedException,
FileAlreadyExistException,
FileDoesNotExistException,
InvalidUpdateRecordException,
MergeConflictException,
Expand Down Expand Up @@ -407,12 +406,8 @@ export class HostTree implements Tree {

// Structural methods.
create(path: string, content: Buffer | string): void {
const p = this._normalizePath(path);
if (this._recordSync.exists(p)) {
throw new FileAlreadyExistException(p);
}
const c = typeof content == 'string' ? Buffer.from(content) : content;
this._record.create(p, c as {} as virtualFs.FileBuffer).subscribe();
this._record.create(this._normalizePath(path), c as {} as virtualFs.FileBuffer).subscribe();
}
delete(path: string): void {
this._recordSync.delete(this._normalizePath(path));
Expand Down
51 changes: 51 additions & 0 deletions tests/legacy-cli/e2e/tests/generate/schematic-force-override.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { appendFile } from 'node:fs/promises';
import { getGlobalVariable } from '../../utils/env';
import { getActivePackageManager, installWorkspacePackages } from '../../utils/packages';
import { ng } from '../../utils/process';
import { isPrereleaseCli, updateJsonFile } from '../../utils/project';
import { expectToFail } from '../../utils/utils';

const snapshots = require('../../ng-snapshot/package.json');

export default async function () {
const isPrerelease = await isPrereleaseCli();
let tag = isPrerelease ? '@next' : '';
if (getActivePackageManager() === 'npm') {
await appendFile('.npmrc', '\nlegacy-peer-deps=true');
}

await ng('add', `@angular/material${tag}`, '--skip-confirmation');

const isSnapshotBuild = getGlobalVariable('argv')['ng-snapshots'];
if (isSnapshotBuild) {
await updateJsonFile('package.json', (packageJson) => {
const dependencies = packageJson['dependencies'];
// Angular material adds dependencies on other Angular packages
// Iterate over all of the packages to update them to the snapshot version.
for (const [name, version] of Object.entries(snapshots.dependencies)) {
if (name in dependencies) {
dependencies[name] = version;
}
}
});
await installWorkspacePackages();
}

const args: string[] = [
'generate',
'@angular/material:theme-color',
'--primary-color=#0641e6',
'--tertiary-color=#994aff',
'--neutral-color=#313138',
'--error-color=#eb5757',
'--secondary-color=#009096',
'--neutral-variant-color=#b2b2b8',
];

await ng(...args);

// Should fail as file exists
await expectToFail(() => ng(...args));

await ng(...args, '--force');
}
Loading