fix(nx): create-nx-workspace creates an extra yarn.lock

This commit is contained in:
Victor Savkin 2019-06-05 07:09:27 -04:00
parent 6dea3f05d0
commit 82f53c94fc
2 changed files with 16 additions and 6 deletions

View File

@ -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(
@ -123,7 +126,8 @@ function addDependencies(options: Schema) {
},
{
'@nrwl/nest': nxVersion
}
},
false
);
}
}

View File

@ -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;
@ -104,6 +105,7 @@ export class NoopChange implements Change {
description = 'No operation.';
order = Infinity;
path = null;
apply() {
return Promise.resolve();
}
@ -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,
@ -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;
}