forked from AgoraIO-Community/app-builder-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdevSetup.js
More file actions
65 lines (58 loc) · 1.32 KB
/
devSetup.js
File metadata and controls
65 lines (58 loc) · 1.32 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
const path = require('path')
const fs = require('fs/promises');
const ROOT = path.join(process.cwd(),'template');
console.log('\n\n\tConfiguring the project for dev environment')
const dotFiles = [
'_buckconfig',
'_eslintrc.js',
'_gitattributes',
'_prettierrc.js',
'_watchmanconfig',
]
async function processDotfiles(){
try{
let dotPromises = [];
const files = await fs.readdir(ROOT);
files.forEach(async (file) => {
if(dotFiles.includes(file)){
const baseFileName = file.slice(1);
dotPromises.push(fs.copyFile(
path.join(ROOT,`_${baseFileName}`),
path.join(ROOT,`.${baseFileName}`),
))
}
})
await Promise.all(dotPromises);
console.log('\t✓ Generated dot files\n')
}
catch(e){
console.error(e);
}
}
async function copyConfig(){
try{
await fs.copyFile(
path.join(process.cwd(),'config.json'),
path.join(ROOT,'config.json'),
)
console.log('\t✓ Added dev config in the template')
}
catch(e){
console.error(e);
}
}
async function copyTheme(){
try{
await fs.copyFile(
path.join(process.cwd(),'theme.json'),
path.join(ROOT,'theme.json'),
)
console.log('\t✓ Added theme in the template')
}
catch(e){
console.error(e);
}
}
processDotfiles();
copyConfig();
copyTheme();