Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(core): remove generator should work w/o workspace.json (#8077)
- Loading branch information
1 parent
ec24422
commit ea26751
Showing
2 changed files
with
16 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 14 additions & 9 deletions
23
packages/workspace/src/generators/move/lib/update-build-targets.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,23 @@ | ||
import { getWorkspacePath, Tree, updateJson } from '@nrwl/devkit'; | ||
import { getProjects, Tree, updateProjectConfiguration } from '@nrwl/devkit'; | ||
import { NormalizedSchema } from '../schema'; | ||
|
||
/** | ||
* Update other references to the source project's targets | ||
*/ | ||
export function updateBuildTargets(tree: Tree, schema: NormalizedSchema) { | ||
updateJson(tree, getWorkspacePath(tree), (json) => { | ||
const strWorkspace = JSON.stringify(json); | ||
json = JSON.parse( | ||
strWorkspace.replace( | ||
new RegExp(`${schema.projectName}:`, 'g'), | ||
`${schema.newProjectName}:` | ||
) | ||
getProjects(tree).forEach((projectConfig, project) => { | ||
Object.entries(projectConfig.targets || {}).forEach( | ||
([target, targetConfig]) => { | ||
const configString = JSON.stringify(targetConfig); | ||
const updated = JSON.parse( | ||
configString.replace( | ||
new RegExp(`${schema.projectName}:`, 'g'), | ||
`${schema.newProjectName}:` | ||
) | ||
); | ||
projectConfig.targets[target] = updated; | ||
} | ||
); | ||
return json; | ||
updateProjectConfiguration(tree, project, projectConfig); | ||
}); | ||
} |