-
Notifications
You must be signed in to change notification settings - Fork 110
Expand file tree
/
Copy pathoptions.ts
More file actions
42 lines (34 loc) · 943 Bytes
/
options.ts
File metadata and controls
42 lines (34 loc) · 943 Bytes
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
import path from 'node:path';
import { fileURLToPath } from 'node:url';
export interface CreateOptions {
_: Array<string | number>;
install?: boolean;
start?: boolean;
git?: boolean;
enterprise?: string;
dir?: string;
dryRun?: boolean;
defaults?: boolean;
packageManager?: string;
force?: boolean;
provider?: string;
}
const __dirname = path.dirname(fileURLToPath(import.meta.url));
export const templatePath = path.resolve(__dirname, process.env.TUTORIALKIT_TEMPLATE_PATH ?? '../_template');
export const DEFAULT_VALUES = {
git: !process.env.CI,
install: true,
start: true,
dryRun: false,
force: false,
packageManager: 'npm',
provider: 'skip',
};
type Flags = Omit<CreateOptions, '_'>;
export function readFlag<Flag extends keyof Flags>(flags: Flags, flag: Flag): Flags[Flag] {
let value = flags[flag];
if (flags.defaults) {
value ??= (DEFAULT_VALUES as Flags)[flag];
}
return value;
}