-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustomize.js
More file actions
36 lines (29 loc) · 826 Bytes
/
customize.js
File metadata and controls
36 lines (29 loc) · 826 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
import { existsSync, readFileSync, writeFileSync } from 'node:fs'
import { join } from 'node:path'
const files = [
'app/App.tsx',
'test/basic.test.tsx',
'test/docs.test.tsx',
'test/tsconfig.json',
'.gitignore',
'babel.config.json',
'create-app.js',
'index.tsx',
'package.json',
'README.md',
'tsconfig.json',
]
// Replace template values with plugin name.
export default (name, directory) => {
const replaceTemplateVariables = (file) => {
const filePath = join(directory, file)
if (!existsSync(filePath)) {
return
}
let contents = readFileSync(filePath, 'utf-8')
contents = contents.replace(/<%= name %>/g, name.regular)
contents = contents.replace(/<%= pascal %>/g, name.pascal)
writeFileSync(filePath, contents)
}
files.forEach(replaceTemplateVariables)
}