Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/@angular/cli/commands/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,12 @@ export default Command.extend({
const cwd = this.project.root;
const schematicName = rawArgs[0];

if (schematicName === 'component' || schematicName === 'directive') {
if (commandOptions.prefix === undefined) {
commandOptions.prefix = appConfig.prefix;
}
}

const SchematicRunTask = require('../tasks/schematic-run').default;
const schematicRunTask = new SchematicRunTask({
ui: this.ui,
Expand Down
21 changes: 21 additions & 0 deletions tests/e2e/tests/generate/component/component-prefix.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import {join} from 'path';
import {ng} from '../../../utils/process';
import {expectFileToMatch} from '../../../utils/fs';
import { updateJsonFile } from '../../../utils/project';


export default function() {
const componentDir = join('src', 'app', 'test-component');

return Promise.resolve()
.then(() => updateJsonFile('.angular-cli.json', configJson => {
const app = configJson['apps'][0];
app['prefix'] = 'pre';
}))
.then(() => ng('generate', 'component', 'test-component'))
.then(() => expectFileToMatch(join(componentDir, 'test-component.component.ts'),
/selector: 'pre-/))

// Try to run the unit tests.
.then(() => ng('test', '--single-run'));
}
21 changes: 21 additions & 0 deletions tests/e2e/tests/generate/directive/directive-prefix.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import {join} from 'path';
import {ng} from '../../../utils/process';
import {expectFileToMatch} from '../../../utils/fs';
import { updateJsonFile } from '../../../utils/project';


export default function() {
const directiveDir = join('src', 'app');

return Promise.resolve()
.then(() => updateJsonFile('.angular-cli.json', configJson => {
const app = configJson['apps'][0];
app['prefix'] = 'pre';
}))
.then(() => ng('generate', 'directive', 'test-directive'))
.then(() => expectFileToMatch(join(directiveDir, 'test-directive.directive.ts'),
/selector: '\[pre/))

// Try to run the unit tests.
.then(() => ng('test', '--single-run'));
}