8
8
9
9
import {
10
10
Rule ,
11
- SchematicsException ,
12
11
Tree ,
13
12
apply ,
14
13
applyTemplates ,
@@ -25,6 +24,7 @@ import { addDeclarationToModule, addExportToModule } from '../utility/ast-utils'
25
24
import { InsertChange } from '../utility/change' ;
26
25
import { buildRelativePath , findModuleFromOptions } from '../utility/find-module' ;
27
26
import { parseName } from '../utility/parse-name' ;
27
+ import { validateClassName } from '../utility/validation' ;
28
28
import { createDefaultPath } from '../utility/workspace' ;
29
29
import { Schema as PipeOptions } from './schema' ;
30
30
@@ -84,15 +84,13 @@ function addDeclarationToNgModule(options: PipeOptions): Rule {
84
84
85
85
export default function ( options : PipeOptions ) : Rule {
86
86
return async ( host : Tree ) => {
87
- if ( options . path === undefined ) {
88
- options . path = await createDefaultPath ( host , options . project as string ) ;
89
- }
90
-
87
+ options . path ??= await createDefaultPath ( host , options . project as string ) ;
91
88
options . module = findModuleFromOptions ( host , options ) ;
92
89
93
90
const parsedPath = parseName ( options . path , options . name ) ;
94
91
options . name = parsedPath . name ;
95
92
options . path = parsedPath . path ;
93
+ validateClassName ( options . name ) ;
96
94
97
95
const templateSource = apply ( url ( './files' ) , [
98
96
options . skipTests ? filter ( ( path ) => ! path . endsWith ( '.spec.ts.template' ) ) : noop ( ) ,
0 commit comments