Skip to content

Commit 9d36016

Browse files
brandonrobertsMikeRyanDev
authored andcommitted
fix(Effects): Added defaults for ng-add schematic
1 parent ff7dc72 commit 9d36016

File tree

3 files changed

+10
-15
lines changed

3 files changed

+10
-15
lines changed

modules/effects/schematics/ng-add/index.spec.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe('Effect ng-add Schematic', () => {
2222
skipPackageJson: false,
2323
project: 'bar',
2424
spec: true,
25-
module: undefined,
25+
module: 'app',
2626
flat: false,
2727
group: false,
2828
};
@@ -66,14 +66,12 @@ describe('Effect ng-add Schematic', () => {
6666
).toBeGreaterThanOrEqual(0);
6767
});
6868

69-
it('should not be provided by default', () => {
69+
it('should be provided by default', () => {
7070
const options = { ...defaultOptions };
7171

7272
const tree = schematicRunner.runSchematic('ng-add', options, appTree);
7373
const content = tree.readContent(`${projectPath}/src/app/app.module.ts`);
74-
expect(content).not.toMatch(
75-
/import { FooEffects } from '.\/foo\/foo.effects'/
76-
);
74+
expect(content).toMatch(/import { FooEffects } from '.\/foo\/foo.effects'/);
7775
});
7876

7977
it('should import into a specified module', () => {
@@ -112,7 +110,7 @@ describe('Effect ng-add Schematic', () => {
112110
});
113111

114112
it('should register the root effect in the provided module', () => {
115-
const options = { ...defaultOptions, module: 'app.module.ts' };
113+
const options = { ...defaultOptions };
116114

117115
const tree = schematicRunner.runSchematic('ng-add', options, appTree);
118116
const content = tree.readContent(`${projectPath}/src/app/app.module.ts`);

modules/effects/schematics/ng-add/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,6 @@ export default function(options: RootEffectOptions): Rule {
136136
]);
137137

138138
return chain([
139-
options && options.skipPackageJson
140-
? noop()
141-
: addNgRxEffectsToPackageJson(),
142139
branchAndMerge(
143140
chain([
144141
filter(
@@ -150,6 +147,9 @@ export default function(options: RootEffectOptions): Rule {
150147
mergeWith(templateSource),
151148
])
152149
),
150+
options && options.skipPackageJson
151+
? noop()
152+
: addNgRxEffectsToPackageJson(),
153153
])(host, context);
154154
};
155155
}

modules/effects/schematics/ng-add/schema.json

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@
77
"name": {
88
"description": "The name of the effect.",
99
"type": "string",
10-
"$default": {
11-
"$source": "argv",
12-
"index": 0
13-
}
10+
"default": "App"
1411
},
1512
"skipPackageJson": {
1613
"type": "boolean",
@@ -21,7 +18,7 @@
2118
"path": {
2219
"type": "string",
2320
"format": "path",
24-
"description": "The path to create the component.",
21+
"description": "The path to create the effect.",
2522
"visible": false
2623
},
2724
"flat": {
@@ -36,7 +33,7 @@
3633
},
3734
"module": {
3835
"type": "string",
39-
"default": "",
36+
"default": "app",
4037
"description": "Allows specification of the declaring module.",
4138
"alias": "m",
4239
"subtype": "filepath"

0 commit comments

Comments
 (0)