8000 feature(generate): configure spec generation at the project level (#2… · jasonruesch/angular-cli@3a3feaf · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3a3feaf

Browse files
authored
feature(generate): configure spec generation at the project level (angular#2475)
Fixes angular#2448
1 parent 0162f71 commit 3a3feaf

File tree

9 files changed

+69
-7
lines changed

9 files changed

+69
-7
lines changed

packages/angular-cli/blueprints/class/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module.exports = {
1111
],
1212

1313
availableOptions: [
14-
{ name: 'spec', type: Boolean, default: true }
14+
{ name: 'spec', type: Boolean }
1515
],
1616

1717
normalizeEntityName: function (entityName) {
@@ -27,6 +27,11 @@ module.exports = {
2727
if (classType) {
2828
this.fileName += '.' + classType;
2929
}
30+
31+
options.spec = options.spec !== undefined ?
32+
options.spec :
33+
this.project.ngConfigObj.get('defaults.spec.class');
34+
3035
return {
3136
dynamicPath: this.dynamicPath.dir,
3237
flat: options.flat,

packages/angular-cli/blueprints/component/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ module.exports = {
1616
{ name: 'inline-template', type: Boolean, aliases: ['it'] },
1717
{ name: 'inline-style', type: Boolean, aliases: ['is'] },
1818
{ name: 'prefix', type: Boolean, default: true },
19-
{ name: 'spec', type: Boolean, default: true }
19+
{ name: 'spec', type: Boolean }
2020
],
2121

2222
beforeInstall: function() {
@@ -64,6 +64,10 @@ module.exports = {
6464
options.inlineTemplate :
6565
this.project.ngConfigObj.get('defaults.inline.template');
6666

67+
options.spec = options.spec !== undefined ?
68+
options.spec :
69+
this.project.ngConfigObj.get('defaults.spec.component');
70+
6771
return {
6872
dynamicPath: this.dynamicPath.dir.replace(this.dynamicPath.appRoot, ''),
6973
flat: options.flat,

packages/angular-cli/blueprints/directive/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module.exports = {
1313
availableOptions: [
1414
{ name: 'flat', type: Boolean, default: true },
1515
{ name: 'prefix', type: Boolean, default: true },
16-
{ name: 'spec', type: Boolean, default: true }
16+
{ name: 'spec', type: Boolean }
1717
],
1818

1919
beforeInstall: function() {
@@ -42,6 +42,10 @@ module.exports = {
4242
},
4343

4444
locals: function (options) {
45+
options.spec = options.spec !== undefined ?
46+
options.spec :
47+
this.project.ngConfigObj.get('defaults.spec.directive');
48+
4549
return {
4650
dynamicPath: this.dynamicPath.dir,
4751
flat: options.flat,

packages/angular-cli/blueprints/module/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module.exports = {
77
description: '',
88

99
availableOptions: [
10-
{ name: 'spec', type: Boolean, default: false },
10+
{ name: 'spec', type: Boolean },
1111
{ name: 'routing', type: Boolean, default: false }
1212
],
1313

@@ -20,6 +20,10 @@ module.exports = {
2020
},
2121

2222
locals: function (options) {
23+
options.spec = options.spec !== undefined ?
24+
options.spec :
25+
this.project.ngConfigObj.get('defaults.spec.module');
26+
2327
return {
2428
dynamicPath: this.dynamicPath.dir,
2529
spec: options.spec,

packages/angular-cli/blueprints/pipe/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module.exports = {
1212

1313
availableOptions: [
1414
{ name: 'flat', type: Boolean, default: true },
15-
{ name: 'spec', type: Boolean, default: true }
15+
{ name: 'spec', type: Boolean }
1616
],
1717

1818
beforeInstall: function() {
@@ -31,6 +31,10 @@ module.exports = {
3131
},
3232

3333
locals: function (options) {
34+
options.spec = options.spec !== undefined ?
35+
options.spec :
36+
this.project.ngConfigObj.get('defaults.spec.pipe');
37+
3438
return {
3539
dynamicPath: this.dynamicPath.dir,
3640
flat: options.flat

packages/angular-cli/blueprints/service/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module.exports = {
99

1010
availableOptions: [
1111
{ name: 'flat', type: Boolean, default: true },
12-
{ name: 'spec', type: Boolean, default: true }
12+
{ name: 'spec', type: Boolean }
1313
],
1414

1515
normalizeEntityName: function (entityName) {
@@ -20,6 +20,10 @@ module.exports = {
2020
},
2121

2222
locals: function (options) {
23+
options.spec = options.spec !== undefined ?
24+
options.spec :
25+
this.project.ngConfigObj.get('defaults.spec.service');
26+
2327
return {
2428
dynamicPath: this.dynamicPath.dir,
2529
flat: options.flat
10000

packages/angular-cli/lib/config/schema.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,13 @@ export interface CliConfig {
6464
style?: boolean;
6565
template?: boolean;
6666
};
67+
spec?: {
68+
class?: boolean;
69+
component?: boolean;
70+
directive?: boolean;
71+
module?: boolean;
72+
pipe?: boolean;
73+
service?: boolean;
74+
};
6775
};
6876
}

packages/angular-cli/lib/config/schema.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,35 @@
151151
"default": false
152152
}
153153
}
154+
},
155+
"spec": {
156+
"type": "object",
157+
"properties": {
158+
"class": {
159+
"type": "boolean",
160+
"default": false
161+
},
162+
"component": {
163+
"type": "boolean",
164+
"default": true
165+
},
166+
"directive": {
167+
"type": "boolean",
168+
"default": true
169+
},
170+
"module": {
171+
"type": "boolean",
172+
"default": false
173+
},
174+
"pipe": {
175+
"type": "boolean",
176+
"default": true
177+
},
178+
"service": {
179+
"type": "boolean",
180+
"default": true
181+
}
182+
}
154183
}
155184
},
156185
"additionalProperties": false

tests/acceptance/generate-class.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ describe('Acceptance: ng generate class', function () {
3232
it('ng generate class my-class', function () {
3333
return ng(['generate', 'class', 'my-class']).then(() => {
3434
expect(existsSync(path.join(testPath, 'my-class.ts'))).to.equal(true);
35-
expect(existsSync(path.join(testPath, 'my-class.spec.ts'))).to.equal(true);
35+
expect(existsSync(path.join(testPath, 'my-class.spec.ts'))).to.equal(false);
3636
});
3737
});
3838

0 commit comments

Comments
 (0)
0