File tree Expand file tree Collapse file tree 3 files changed +48
-0
lines changed
packages/@angular/cli/commands Expand file tree Collapse file tree 3 files changed +48
-0
lines changed Original file line number Diff line number Diff line change @@ -145,6 +145,12 @@ export default Command.extend({
145145 const cwd = this . project . root ;
146146 const schematicName = rawArgs [ 0 ] ;
147147
148+ if ( schematicName === 'component' || schematicName === 'directive' ) {
149+ if ( commandOptions . prefix === undefined ) {
150+ commandOptions . prefix = appConfig . prefix ;
151+ }
152+ }
153+
148154 const SchematicRunTask = require ( '../tasks/schematic-run' ) . default ;
149155 const schematicRunTask = new SchematicRunTask ( {
150156 ui : this . ui ,
Original file line number Diff line number Diff line change 1+ import { join } from 'path' ;
2+ import { ng } from '../../../utils/process' ;
3+ import { expectFileToMatch } from '../../../utils/fs' ;
4+ import { updateJsonFile } from '../../../utils/project' ;
5+
6+
7+ export default function ( ) {
8+ const componentDir = join ( 'src' , 'app' , 'test-component' ) ;
9+
10+ return Promise . resolve ( )
11+ . then ( ( ) => updateJsonFile ( '.angular-cli.json' , configJson => {
12+ const app = configJson [ 'apps' ] [ 0 ] ;
13+ app [ 'prefix' ] = 'pre' ;
14+ } ) )
15+ . then ( ( ) => ng ( 'generate' , 'component' , 'test-component' ) )
16+ . then ( ( ) => expectFileToMatch ( join ( componentDir , 'test-component.component.ts' ) ,
17+ / s e l e c t o r : ' p r e - / ) )
18+
19+ // Try to run the unit tests.
20+ . then ( ( ) => ng ( 'test' , '--single-run' ) ) ;
21+ }
Original file line number Diff line number Diff line change 1+ import { join } from 'path' ;
2+ import { ng } from '../../../utils/process' ;
3+ import { expectFileToMatch } from '../../../utils/fs' ;
4+ import { updateJsonFile } from '../../../utils/project' ;
5+
6+
7+ export default function ( ) {
8+ const directiveDir = join ( 'src' , 'app' ) ;
9+
10+ return Promise . resolve ( )
11+ . then ( ( ) => updateJsonFile ( '.angular-cli.json' , configJson => {
12+ const app = configJson [ 'apps' ] [ 0 ] ;
13+ app [ 'prefix' ] = 'pre' ;
14+ } ) )
15+ . then ( ( ) => ng ( 'generate' , 'directive' , 'test-directive' ) )
16+ . then ( ( ) => expectFileToMatch ( join ( directiveDir , 'test-directive.directive.ts' ) ,
17+ / s e l e c t o r : ' \[ p r e / ) )
18+
19+ // Try to run the unit tests.
20+ . then ( ( ) => ng ( 'test' , '--single-run' ) ) ;
21+ }
You can’t perform that action at this time.
0 commit comments