Hoon Oh f30b8a318d
fix(nest): add missing resource generator option (#8310)
Co-authored-by: hoonoh <hoonoh@users.noreply.github.com>
2022-01-13 10:15:50 -05:00

42 lines
1.0 KiB
TypeScript

import type { Tree } from '@nrwl/devkit';
import { convertNxGenerator } from '@nrwl/devkit';
import type {
NestGeneratorWithLanguageOption,
NestGeneratorWithResourceOption,
NestGeneratorWithTestOption,
NormalizedOptions,
} from '../utils';
import {
normalizeOptions,
runNestSchematic,
unitTestRunnerToSpec,
} from '../utils';
export type ResourceGeneratorOptions = NestGeneratorWithLanguageOption &
NestGeneratorWithTestOption &
NestGeneratorWithResourceOption;
export function resourceGenerator(
tree: Tree,
rawOptions: ResourceGeneratorOptions
): Promise<any> {
const options = normalizeResourceOptions(tree, rawOptions);
return runNestSchematic(tree, 'resource', options);
}
export default resourceGenerator;
export const resourceSchematic = convertNxGenerator(resourceGenerator);
function normalizeResourceOptions(
tree: Tree,
options: ResourceGeneratorOptions
): NormalizedOptions {
return {
...normalizeOptions(tree, options),
language: options.language,
spec: unitTestRunnerToSpec(options.unitTestRunner),
};
}