-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
normalize-options.ts
48 lines (44 loc) · 1.39 KB
/
normalize-options.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { names, Tree } from '@nx/devkit';
import { determineProjectNameAndRootOptions } from '@nx/devkit/src/generators/project-name-and-root-utils';
import { Schema } from '../schema';
export interface NormalizedSchema extends Schema {
className: string;
projectName: string;
appProjectRoot: string;
lowerCaseName: string;
parsedTags: string[];
}
export async function normalizeOptions(
host: Tree,
options: Schema
): Promise<NormalizedSchema> {
const {
projectName: appProjectName,
names: projectNames,
projectRoot: appProjectRoot,
projectNameAndRootFormat,
} = await determineProjectNameAndRootOptions(host, {
name: options.name,
projectType: 'application',
directory: options.directory,
projectNameAndRootFormat: options.projectNameAndRootFormat,
callingGenerator: '@nx/expo:application',
});
options.projectNameAndRootFormat = projectNameAndRootFormat;
const { className } = names(options.name);
const parsedTags = options.tags
? options.tags.split(',').map((s) => s.trim())
: [];
return {
...options,
unitTestRunner: options.unitTestRunner || 'jest',
e2eTestRunner: options.e2eTestRunner || 'detox',
name: projectNames.projectSimpleName,
className,
lowerCaseName: className.toLowerCase(),
displayName: options.displayName || className,
projectName: appProjectName,
appProjectRoot,
parsedTags,
};
}