Skip to content

Commit

Permalink
code review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
santoshyadavdev committed Mar 9, 2019
1 parent 757d04e commit 0b4a3a2
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 69 deletions.
16 changes: 8 additions & 8 deletions modules/effects/schematics-core/utility/ngrx-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ export function addReducerToStateInterface(
return new NoopChange();
}

const state =
options.plural === undefined
? stringUtils.camelize(options.name)
: stringUtils.camelize(options.name) + 's';
let state = stringUtils.camelize(options.name);
if (options.plural) {
state = stringUtils.camelize(options.name) + 's';
}

const keyInsert =
state + ': from' + stringUtils.classify(options.name) + '.State;';
Expand Down Expand Up @@ -154,10 +154,10 @@ export function addReducerToActionReducerMap(

let node = actionReducerMap.initializer;

const state =
options.plural === undefined
? stringUtils.camelize(options.name)
: stringUtils.camelize(options.name) + 's';
let state = stringUtils.camelize(options.name);
if (options.plural) {
state = stringUtils.camelize(options.name) + 's';
}

const keyInsert =
state + ': from' + stringUtils.classify(options.name) + '.reducer,';
Expand Down
16 changes: 8 additions & 8 deletions modules/entity/schematics-core/utility/ngrx-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ export function addReducerToStateInterface(
return new NoopChange();
}

const state =
options.plural === undefined
? stringUtils.camelize(options.name)
: stringUtils.camelize(options.name) + 's';
let state = stringUtils.camelize(options.name);
if (options.plural) {
state = stringUtils.camelize(options.name) + 's';
}

const keyInsert =
state + ': from' + stringUtils.classify(options.name) + '.State;';
Expand Down Expand Up @@ -154,10 +154,10 @@ export function addReducerToActionReducerMap(

let node = actionReducerMap.initializer;

const state =
options.plural === undefined
? stringUtils.camelize(options.name)
: stringUtils.camelize(options.name) + 's';
let state = stringUtils.camelize(options.name);
if (options.plural) {
state = stringUtils.camelize(options.name) + 's';
}

const keyInsert =
state + ': from' + stringUtils.classify(options.name) + '.reducer,';
Expand Down
16 changes: 8 additions & 8 deletions modules/router-store/schematics-core/utility/ngrx-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ export function addReducerToStateInterface(
return new NoopChange();
}

const state =
options.plural === undefined
? stringUtils.camelize(options.name)
: stringUtils.camelize(options.name) + 's';
let state = stringUtils.camelize(options.name);
if (options.plural) {
state = stringUtils.camelize(options.name) + 's';
}

const keyInsert =
state + ': from' + stringUtils.classify(options.name) + '.State;';
Expand Down Expand Up @@ -154,10 +154,10 @@ export function addReducerToActionReducerMap(

let node = actionReducerMap.initializer;

const state =
options.plural === undefined
? stringUtils.camelize(options.name)
: stringUtils.camelize(options.name) + 's';
let state = stringUtils.camelize(options.name);
if (options.plural) {
state = stringUtils.camelize(options.name) + 's';
}

const keyInsert =
state + ': from' + stringUtils.classify(options.name) + '.reducer,';
Expand Down
16 changes: 8 additions & 8 deletions modules/schematics-core/utility/ngrx-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ export function addReducerToStateInterface(
return new NoopChange();
}

const state =
options.plural === undefined
? stringUtils.camelize(options.name)
: stringUtils.camelize(options.name) + 's';
let state = stringUtils.camelize(options.name);
if (options.plural) {
state = stringUtils.camelize(options.name) + 's';
}

const keyInsert =
state + ': from' + stringUtils.classify(options.name) + '.State;';
Expand Down Expand Up @@ -154,10 +154,10 @@ export function addReducerToActionReducerMap(

let node = actionReducerMap.initializer;

const state =
options.plural === undefined
? stringUtils.camelize(options.name)
: stringUtils.camelize(options.name) + 's';
let state = stringUtils.camelize(options.name);
if (options.plural) {
state = stringUtils.camelize(options.name) + 's';
}

const keyInsert =
state + ': from' + stringUtils.classify(options.name) + '.reducer,';
Expand Down
16 changes: 8 additions & 8 deletions modules/schematics/schematics-core/utility/ngrx-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ export function addReducerToStateInterface(
return new NoopChange();
}

const state =
options.plural === undefined
? stringUtils.camelize(options.name)
: stringUtils.camelize(options.name) + 's';
let state = stringUtils.camelize(options.name);
if (options.plural) {
state = stringUtils.camelize(options.name) + 's';
}

const keyInsert =
state + ': from' + stringUtils.classify(options.name) + '.State;';
Expand Down Expand Up @@ -154,10 +154,10 @@ export function addReducerToActionReducerMap(

let node = actionReducerMap.initializer;

const state =
options.plural === undefined
? stringUtils.camelize(options.name)
: stringUtils.camelize(options.name) + 's';
let state = stringUtils.camelize(options.name);
if (options.plural) {
state = stringUtils.camelize(options.name) + 's';
}

const keyInsert =
state + ': from' + stringUtils.classify(options.name) + '.reducer,';
Expand Down
2 changes: 1 addition & 1 deletion modules/schematics/src/entity/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ describe('Entity Schematic', () => {
).toBeGreaterThanOrEqual(0);
});

it('should create all files of an entity within grouped and nested folders', () => {
it('should update the state to plural', () => {
const options = {
...defaultOptions,
name: 'user',
Expand Down
3 changes: 1 addition & 2 deletions modules/schematics/src/entity/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export default function(options: EntityOptions): Rule {
const parsedPath = parseName(options.path, options.name);
options.name = parsedPath.name;
options.path = parsedPath.path;
options.plural = true;

if (options.module) {
options.module = findModuleFromOptions(host, options);
Expand All @@ -56,7 +55,7 @@ export default function(options: EntityOptions): Rule {
]);

return chain([
addReducerToState({ ...options }),
addReducerToState({ ...options, plural: true }),
addReducerImportToNgModule({ ...options }),
branchAndMerge(chain([mergeWith(templateSource)])),
])(host, context);
Expand Down
5 changes: 0 additions & 5 deletions modules/schematics/src/entity/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,6 @@
"description":
"Group actions, reducers and effects within relative subfolders",
"aliases": ["g"]
},
"plural": {
"type": "boolean",
"default": true,
"description": "Update state with plural."
}
},
"required": []
Expand Down
5 changes: 0 additions & 5 deletions modules/schematics/src/entity/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,4 @@ export interface Schema {
*/

group?: boolean;
/**
* Specifies if this is state and reducer variable will be plural
*/

plural?: boolean;
}
16 changes: 8 additions & 8 deletions modules/store-devtools/schematics-core/utility/ngrx-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ export function addReducerToStateInterface(
return new NoopChange();
}

const state =
options.plural === undefined
? stringUtils.camelize(options.name)
: stringUtils.camelize(options.name) + 's';
let state = stringUtils.camelize(options.name);
if (options.plural) {
state = stringUtils.camelize(options.name) + 's';
}

const keyInsert =
state + ': from' + stringUtils.classify(options.name) + '.State;';
Expand Down Expand Up @@ -154,10 +154,10 @@ export function addReducerToActionReducerMap(

let node = actionReducerMap.initializer;

const state =
options.plural === undefined
? stringUtils.camelize(options.name)
: stringUtils.camelize(options.name) + 's';
let state = stringUtils.camelize(options.name);
if (options.plural) {
state = stringUtils.camelize(options.name) + 's';
}

const keyInsert =
state + ': from' + stringUtils.classify(options.name) + '.reducer,';
Expand Down
16 changes: 8 additions & 8 deletions modules/store/schematics-core/utility/ngrx-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ export function addReducerToStateInterface(
return new NoopChange();
}

const state =
options.plural === undefined
? stringUtils.camelize(options.name)
: stringUtils.camelize(options.name) + 's';
let state = stringUtils.camelize(options.name);
if (options.plural) {
state = stringUtils.camelize(options.name) + 's';
}

const keyInsert =
state + ': from' + stringUtils.classify(options.name) + '.State;';
Expand Down Expand Up @@ -154,10 +154,10 @@ export function addReducerToActionReducerMap(

let node = actionReducerMap.initializer;

const state =
options.plural === undefined
? stringUtils.camelize(options.name)
: stringUtils.camelize(options.name) + 's';
let state = stringUtils.camelize(options.name);
if (options.plural) {
state = stringUtils.camelize(options.name) + 's';
}

const keyInsert =
state + ': from' + stringUtils.classify(options.name) + '.reducer,';
Expand Down

0 comments on commit 0b4a3a2

Please sign in to comment.