@@ -15,7 +15,7 @@ import {
1515} from '@angular-devkit/schematics/tools' ;
1616import type { CheckboxQuestion , Question } from 'inquirer' ;
1717import { Argv } from 'yargs' ;
18- import { getProjectByCwd , getProjectsByPath , getSchematicDefaults } from '../utilities/config' ;
18+ import { getProjectByCwd , getSchematicDefaults } from '../utilities/config' ;
1919import { isTTY } from '../utilities/tty' ;
2020import {
2121 CommandModule ,
@@ -364,32 +364,23 @@ export abstract class SchematicsCommandModule
364364 return undefined ;
365365 }
366366
367- const projectNames = getProjectsByPath ( workspace , process . cwd ( ) , workspace . basePath ) ;
367+ const projectName = getProjectByCwd ( workspace ) ;
368+ if ( projectName ) {
369+ return projectName ;
370+ }
368371
369- if ( projectNames . length === 1 ) {
370- return projectNames [ 0 ] ;
371- } else {
372- if ( projectNames . length > 1 ) {
372+ const defaultProjectName = workspace . extensions [ 'defaultProject' ] ;
373+ if ( typeof defaultProjectName === 'string' && defaultProjectName ) {
374+ if ( ! this . defaultProjectDeprecationWarningShown ) {
373375 logger . warn ( tags . oneLine `
374- Two or more projects are using identical roots.
375- Unable to determine project using current working directory.
376- Using default workspace project instead.
377- ` ) ;
378- }
379-
380- const defaultProjectName = workspace . extensions [ 'defaultProject' ] ;
381- if ( typeof defaultProjectName === 'string' && defaultProjectName ) {
382- if ( ! this . defaultProjectDeprecationWarningShown ) {
383- logger . warn ( tags . oneLine `
384376 DEPRECATED: The 'defaultProject' workspace option has been deprecated.
385377 The project to use will be determined from the current working directory.
386378 ` ) ;
387379
388- this . defaultProjectDeprecationWarningShown = true ;
389- }
390-
391- return defaultProjectName ;
380+ this . defaultProjectDeprecationWarningShown = true ;
392381 }
382+
383+ return defaultProjectName ;
393384 }
394385
395386 return undefined ;
0 commit comments