File tree Expand file tree Collapse file tree 1 file changed +21
-3
lines changed Expand file tree Collapse file tree 1 file changed +21
-3
lines changed Original file line number Diff line number Diff line change 1- import { Tree , serializeJson , readJson } from '@nx/devkit' ;
1+ import { Tree , serializeJson , readJson , readNxJson } from '@nx/devkit' ;
22import { stringUtils as nxStringUtils } from '@nx/workspace' ;
33
44export interface IPluginSettings {
@@ -33,8 +33,26 @@ let frontendFramework: FrameworkTypes;
3333let groupByName = false ;
3434let usingXplatWorkspace = false ;
3535
36- export function getNpmScope ( ) {
37- return npmScope ;
36+ export function getNpmScope ( tree ?: Tree ) {
37+ if ( npmScope ) {
38+ return npmScope ;
39+ }
40+ const nxJson = readNxJson ( tree ) ;
41+
42+ // TODO(v17): Remove reading this from nx.json
43+ if ( nxJson . npmScope ) {
44+ npmScope = nxJson . npmScope ;
45+ return npmScope ;
46+ }
47+
48+ const { name } = tree . exists ( 'package.json' )
49+ ? readJson < { name ?: string } > ( tree , 'package.json' )
50+ : { name : null } ;
51+
52+ if ( name ?. startsWith ( '@' ) ) {
53+ npmScope = name . split ( '/' ) [ 0 ] . substring ( 1 ) ;
54+ return npmScope ;
55+ }
3856}
3957
4058export function getPrefix ( ) {
You can’t perform that action at this time.
0 commit comments