import { chain, externalSchematic, Rule } from '@angular-devkit/schematics';
import { Schema as NgComponentOptions } from '@schematics/angular/component/schema';

export interface ScamOptions extends NgComponentOptions {
    separateModule: boolean;
}

export const _mergeModuleIntoComponentFile: Rule = (tree, context) => tree;

export function scam(options: ScamOptions): Rule {

    let ruleList = [
        externalSchematic('@schematics/angular', 'module', options),
        externalSchematic('@schematics/angular', 'component', {
            ...options,
            export: true,
            module: options.name
        })
    ];

    if (!options.separateModule) {
        ruleList = [
            ...ruleList,
            _mergeModuleIntoComponentFile
        ];
    }

    return chain(ruleList);

}

import { chain, externalSchematic, Rule } from '@angular-devkit/schematics';
import { Schema as NgComponentOptions } from '@schematics/angular/component/schema';

export interface ScamOptions extends NgComponentOptions {
    separateModule: boolean;
}

export function scam(options: ScamOptions): Rule {

    let ruleList = [
        externalSchematic('@schematics/angular', 'module', options),
        externalSchematic('@schematics/angular', 'component', {
            ...options,
            export: true,
            module: options.name
        })
    ];

    if (!options.separateModule) {
        ruleList = [
            ...ruleList
        ];
    }

    return chain(ruleList);

}

--- 
+++ 
@@ -4,6 +4,8 @@
 export interface ScamOptions extends NgComponentOptions {
     separateModule: boolean;
 }
+
+export const _mergeModuleIntoComponentFile: Rule = (tree, context) => tree;
 
 export function scam(options: ScamOptions): Rule {
 
@@ -18,7 +20,8 @@
 
     if (!options.separateModule) {
         ruleList = [
-            ...ruleList
+            ...ruleList,
+            _mergeModuleIntoComponentFile
         ];
     }
 
@wishtack/schematics:scam: Merge module and component as default behavior.
