Skip to content

Commit

Permalink
fix(nx): create-nx-workspace creates an extra yarn.lock
Browse files Browse the repository at this point in the history
  • Loading branch information
vsavkin committed Jun 5, 2019
1 parent 6dea3f0 commit 82f53c9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
12 changes: 8 additions & 4 deletions packages/workspace/src/schematics/ng-new/ng-new.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,21 +100,24 @@ function addDependencies(options: Schema) {
{
'@nrwl/angular': nxVersion
},
{}
{},
false
);
} else if (options.preset === 'react') {
return addDepsToPackageJson(
{},
{
'@nrwl/react': nxVersion
}
},
false
);
} else if (options.preset === 'web-components') {
return addDepsToPackageJson(
{},
{
'@nrwl/web': nxVersion
}
},
false
);
} else {
return addDepsToPackageJson(
Expand All @@ -123,7 +126,8 @@ function addDependencies(options: Schema) {
},
{
'@nrwl/nest': nxVersion
}
},
false
);
}
}
Expand Down
10 changes: 8 additions & 2 deletions packages/workspace/src/utils/ast-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export function getSourceNodes(sourceFile: ts.SourceFile): ts.Node[] {

export interface Change {
apply(host: any): Promise<void>;

readonly type: string;
readonly path: string | null;
readonly order: number;
Expand All @@ -104,6 +105,7 @@ export class NoopChange implements Change {
description = 'No operation.';
order = Infinity;
path = null;

apply() {
return Promise.resolve();
}
Expand Down Expand Up @@ -392,7 +394,11 @@ export function updateJsonInTree<T = any, O = T>(

let installAdded = false;

export function addDepsToPackageJson(deps: any, devDeps: any): Rule {
export function addDepsToPackageJson(
deps: any,
devDeps: any,
addInstall = true
): Rule {
return updateJsonInTree('package.json', (json, context: SchematicContext) => {
json.dependencies = {
...deps,
Expand All @@ -402,7 +408,7 @@ export function addDepsToPackageJson(deps: any, devDeps: any): Rule {
...devDeps,
...(json.devDependencies || {})
};
if (!installAdded) {
if (addInstall && !installAdded) {
context.addTask(new NodePackageInstallTask());
installAdded = true;
}
Expand Down

0 comments on commit 82f53c9

Please sign in to comment.