Skip to content
This repository has been archived by the owner on May 1, 2020. It is now read-only.

Commit

Permalink
fix(generators): handle old cli
Browse files Browse the repository at this point in the history
  • Loading branch information
mhartington committed Jul 27, 2017
1 parent 34fc05b commit 6fd622c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
20 changes: 13 additions & 7 deletions src/generators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ import { hydrateRequest, hydrateTabRequest, getNgModules, GeneratorOption, Gener

export { getNgModules, GeneratorOption, GeneratorRequest };

export function processPageRequest(context: BuildContext, name: string, commandOptions: any) {

const hydratedRequest = hydrateRequest(context, { type: 'page', name, includeNgModule: commandOptions.module });
return generateTemplates(context, hydratedRequest, commandOptions.constants);
export function processPageRequest(context: BuildContext, name: string, commandOptions?: { module?: boolean; constants?: boolean; }) {
if (commandOptions) {
const hydratedRequest = hydrateRequest(context, { type: 'page', name, includeNgModule: commandOptions.module });
return generateTemplates(context, hydratedRequest, commandOptions.constants);
}else {
const hydratedRequest = hydrateRequest(context, { type: 'page', name, includeNgModule: false });
return generateTemplates(context, hydratedRequest);
}
}

export function processPipeRequest(context: BuildContext, name: string, ngModulePath: string) {
Expand All @@ -26,9 +30,11 @@ export function processProviderRequest(context: BuildContext, name: string, ngMo
return nonPageFileManipulation(context, name, ngModulePath, 'provider');
}

export function processTabsRequest(context: BuildContext, name: string, tabs: any[], commandOptions: any) {
const includePageConstants = commandOptions.constants;
const includeNgModule = commandOptions.module;
export function processTabsRequest(context: BuildContext, name: string, tabs: any[], commandOptions?: { module?: boolean; constants?: boolean; }) {

const includePageConstants = commandOptions ? commandOptions.constants : false;
const includeNgModule = commandOptions ? commandOptions.module : false;

const tabHydratedRequests = tabs.map((tab) => hydrateRequest(context, { type: 'page', name: tab, includeNgModule}));
const hydratedRequest = hydrateTabRequest(context, { type: 'tabs', name, includeNgModule, tabs: tabHydratedRequests });

Expand Down
2 changes: 1 addition & 1 deletion src/generators/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ export function tabsModuleManipulation(tabs: string[][], hydratedRequest: Hydrat

}

export function generateTemplates(context: BuildContext, request: HydratedGeneratorRequest, includePageConstants: any): Promise<string[]> {
export function generateTemplates(context: BuildContext, request: HydratedGeneratorRequest, includePageConstants?: boolean): Promise<string[]> {
Logger.debug('[Generators] generateTemplates: Reading templates ...');

let pageConstantFile = join(context.pagesDir, 'pages.constants.ts');
Expand Down

0 comments on commit 6fd622c

Please sign in to comment.