-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.js
97 lines (68 loc) · 2.28 KB
/
init.js
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
const fs = require('fs');
// import fs from 'fs';
const createDir = (dirpath) => {
console.log('Creating dir:', dirpath);
fs.mkdirSync(process.cwd() + dirpath, { recursive: true }, (error) => {
if (error) {
console.error('An error occurred:', error);
} else {
console.log('Your directory is made');
}
});
}
const createFile = (filePath, fileContent) => {
console.log('Creating file:', filePath);
fs.writeFile(filePath, fileContent, (error) => {
if (error) {
console.error('An error occurred:', error);
} else {
console.log('Your file: '+filePath+' is made');
}
})
}
console.log('--------Start Scripts--------');
const paths = {
default: '/',
current:'./',
src: {
default: 'src',
scss: 'src/scss',
js: 'src/js',
fonts: 'src/fonts',
css: 'src/css',
img: 'src/img',
pug: 'src/pug',
},
};
/*----------------CARPETAS-------------------*/
//Creamos directorio principal
createDir(paths.default+paths.src.default);
//Creamos directorio css
createDir(paths.default+paths.src.css);
//Creamos directorio fonts
createDir(paths.default+paths.src.fonts);
//Creamos directorio img
createDir(paths.default+paths.src.img);
//Creamos directorio js
createDir(paths.default+paths.src.js);
//Creamos directorio pug
createDir(paths.default+paths.src.pug);
//Creamos directorio scss
createDir(paths.default+paths.src.scss);
/*----------------FICHEROS-------------------*/
//Creamos js/scripts.js
createFile(paths.current+paths.src.js+'/scripts.js','');
//Creamos scss/styles.js
createFile(paths.current+paths.src.scss+'/styles.scss','');
//Creamos index.pug y agregamos el template
const pug_data = fs.readFileSync(paths.current+'init/index.pug-template.txt', 'utf8');
createFile(paths.current+paths.src.default+'/index.pug',pug_data);
//Creamos app.js y agregamos el template
const js_data = fs.readFileSync(paths.current+'init/app.js-template.txt', 'utf8');
createFile(paths.current+paths.src.default+'/app.js',js_data);
// const pathDir = '/test';
// const content = 'content of my file';
// createDir(pathDir);
// createFile(`.${pathDir}/text.txt`, content)
// exports.createDir = createDir;
// exports.createFile = createFile;