Skip to content

Commit dbcaf1f

Browse files
committed
Make example code optional
1 parent eaaadd7 commit dbcaf1f

File tree

30 files changed

+23
-5
lines changed

30 files changed

+23
-5
lines changed

src/index.ts

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ type Config = {
2020
githubRepository: string
2121
includeDocs: boolean
2222
includePlayground: boolean
23+
includeExamples: boolean
2324
}
2425

2526
async function init() {
@@ -30,6 +31,7 @@ async function init() {
3031
githubPath?: string
3132
includeDocs: boolean
3233
includePlayground: boolean
34+
includeExamples: boolean
3335
} = {}
3436

3537
try {
@@ -59,6 +61,13 @@ async function init() {
5961
initial: true,
6062
active: 'Yes',
6163
inactive: 'No'
64+
}, {
65+
name: 'includeExamples',
66+
type: 'toggle',
67+
message: 'Include example code?',
68+
initial: true,
69+
active: 'Yes',
70+
inactive: 'No, just configs'
6271
}
6372
],
6473
{
@@ -122,7 +131,8 @@ async function init() {
122131
githubIssues,
123132
githubRepository,
124133
includeDocs: result.includeDocs,
125-
includePlayground: result.includePlayground
134+
includePlayground: result.includePlayground,
135+
includeExamples: result.includeExamples
126136
}
127137

128138
copyTemplate('base', config)
@@ -145,10 +155,18 @@ async function init() {
145155
}
146156

147157
function copyTemplate(templateName: string, config: Config) {
148-
copyFiles('', {
149-
...config,
150-
templateDirPath: path.join(config.templateDirPath, templateName)
151-
})
158+
const dirs = ['config']
159+
160+
if (config.includeExamples) {
161+
dirs.push('examples')
162+
}
163+
164+
for (const dir of dirs) {
165+
copyFiles('', {
166+
...config,
167+
templateDirPath: path.join(config.templateDirPath, templateName, dir)
168+
})
169+
}
152170
}
153171

154172
function copyFiles(templateFile: string, config: Config) {
File renamed without changes.

0 commit comments

Comments
 (0)