Skip to content

Commit 63ce665

Browse files
authored
refactor: remove usage of private buildDefaultPath method from @schematics/angular (#19229)
The internal `project` file will be deleted with this change angular/angular-cli#17597, this copies that implementation to the file were it's needed.
1 parent 0354c8f commit 63ce665

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/cdk/schematics/utils/build-component.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ import {InsertChange} from '@schematics/angular/utility/change';
2727
import {getWorkspace} from '@schematics/angular/utility/config';
2828
import {buildRelativePath, findModuleFromOptions} from '@schematics/angular/utility/find-module';
2929
import {parseName} from '@schematics/angular/utility/parse-name';
30-
import {buildDefaultPath} from '@schematics/angular/utility/project';
3130
import {validateHtmlSelector, validateName} from '@schematics/angular/utility/validation';
31+
import {ProjectType, WorkspaceProject} from '@schematics/angular/utility/workspace-models';
3232
import {readFileSync, statSync} from 'fs';
3333
import {dirname, join, resolve} from 'path';
3434
import * as ts from 'typescript';
@@ -40,6 +40,20 @@ import {
4040
import {getProjectFromWorkspace} from './get-project';
4141
import {getDefaultComponentOptions} from './schematic-options';
4242

43+
/**
44+
* Build a default project path for generating.
45+
* @param project The project to build the path for.
46+
*/
47+
function buildDefaultPath(project: WorkspaceProject): string {
48+
const root = project.sourceRoot
49+
? `/${project.sourceRoot}/`
50+
: `/${project.root}/src/`;
51+
52+
const projectDirName = project.projectType === ProjectType.Application ? 'app' : 'lib';
53+
54+
return `${root}${projectDirName}`;
55+
}
56+
4357
/**
4458
* List of style extensions which are CSS compatible. All supported CLI style extensions can be
4559
* found here: angular/angular-cli/master/packages/schematics/angular/ng-new/schema.json#L118-L122

0 commit comments

Comments
 (0)