mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-16 18:43:42 +08:00
An internal schematics helper rule has been introduced for Angular schematics that only generate a set of project files from a set of templated files. Multiple current generation schematics contained essentially the same code which increased the sustainment burden and made refactoring and improvements more complicated.
22 lines
650 B
TypeScript
22 lines
650 B
TypeScript
/**
|
|
* @license
|
|
* Copyright Google LLC All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
* found in the LICENSE file at https://angular.io/license
|
|
*/
|
|
|
|
import { Rule } from '@angular-devkit/schematics';
|
|
import { generateFromFiles } from '../utility/generate-from-files';
|
|
import { Schema as ServiceOptions } from './schema';
|
|
|
|
export default function (options: ServiceOptions): Rule {
|
|
// This schematic uses an older method to implement the flat option
|
|
const flat = options.flat;
|
|
options.flat = true;
|
|
|
|
return generateFromFiles(options, {
|
|
'if-flat': (s: string) => (flat ? '' : s),
|
|
});
|
|
}
|