Skip to content

Commit

Permalink
fix(schematics): prevent ng-add from rewriting other workspace cli op…
Browse files Browse the repository at this point in the history
…tions (#2731)
  • Loading branch information
eneajaho authored Oct 7, 2020
1 parent bc19015 commit 37354aa
Showing 1 changed file with 12 additions and 20 deletions.
32 changes: 12 additions & 20 deletions modules/schematics/src/ng-add/index.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,17 @@
import {
Rule,
SchematicContext,
Tree,
chain,
noop,
} from '@angular-devkit/schematics';
import {
WorkspaceSchema,
getWorkspacePath,
getWorkspace,
} from '../../schematics-core/utility/config';
import { Schema as SchematicOptions } from './schema';
import {chain, noop, Rule, SchematicContext, Tree,} from '@angular-devkit/schematics';
import {getWorkspace, getWorkspacePath} from '../../schematics-core';

function updateWorkspace<K extends keyof WorkspaceSchema>(
host: Tree,
key: K,
value: any
) {
import {Schema as SchematicOptions} from './schema';

function updateWorkspaceCli(host: Tree, value: any) {
const workspace = getWorkspace(host);
const path = getWorkspacePath(host);
workspace[key] = value;

workspace['cli'] = {
...workspace['cli'],
...value
};

host.overwrite(path, JSON.stringify(workspace, null, 2));
}

Expand All @@ -28,7 +20,7 @@ function setAsDefaultSchematics() {
defaultCollection: '@ngrx/schematics',
};
return (host: Tree) => {
updateWorkspace(host, 'cli', cli);
updateWorkspaceCli(host, cli);
return host;
};
}
Expand Down

0 comments on commit 37354aa

Please sign in to comment.