INNER CODE UNIT · TypeScript

updateProject

maciejtreder/ng-toolkit · schematics/_utils/index.ts:323

export function updateProject(tree: Tree, options: any): void {
    const cliConfig: WorkspaceSchema = JSON.parse(getFileContent(tree, `${options.directory}/angular.json`));
    const project: WorkspaceTargets<ProjectType.Application> | undefined = cliConfig.projects[options.clientProject].architect;
    for (let property in project) {
        if (project.hasOwnProperty(property) && project[property].builder === '@angular-devkit/build-angular:browser') {
            console.log(`\u001B[33mINFO: \u001b[0mProject property is set to '${options.clientProject}'.`);
            return;
        }
    }

    if (project && project.defaultProject) {
        options.clientProject = project.defaultProject;
        console.log(`\u001B[33mINFO: \u001b[0mProject property is set to '${options.clientProject}'.`);
        return;
    }

    // trying with regex - will take first project found with the browser builder
    const angularFileContent: string = getFileContent(tree, `${options.directory}/angular.json`);

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…