-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathv3Maker.js
44 lines (36 loc) · 1.47 KB
/
v3Maker.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
const fs = require('fs-extra');
const fsPromises = require('fs/promises');
const v3elmnts = require('./v3elmnts.json');
const process = require('process');
const readline = require('readline');
// Make the v3 folder in the css folder
var v3Dir = 'css/v3';
if (fs.existsSync(v3Dir)) {
console.log(`Deleting past V3 folder`);
fs.rmSync(v3Dir, { recursive: true });
console.log(`Deleted past V3 folder`);
}
fs.mkdirSync(v3Dir);
// Now we'll replace all the strings in the the v3 elements file with their replacements for v3.
console.log('Making V3 copies of css files...');
var cssFiles = fs.readdirSync('css/');
cssFiles.forEach(cssFileName => {
// Make sure the file is an actual css file
if (cssFileName.endsWith('.css') && cssFileName !== 'forv3.css') {
process.stdout.write(`> ${cssFileName}`);
// Get the css file & path
let cssPath = `css/${cssFileName}`;
let cssFile = fs.readFileSync(cssPath, { encoding: 'utf8' });
// Replace any of the keys in v3elmnts with their value
for (const [key, value] of Object.entries(v3elmnts)) {
cssFile = cssFile.replaceAll(key, value);
}
// Write to a new css file in the v3 folder
fs.writeFileSync(`css/v3/${cssFileName}`, cssFile);
readline.clearLine(process.stdout, 0);
readline.cursorTo(process.stdout, 0, null);
process.stdout.write(`✓ ${cssFileName}\n`);
};
});
console.log(`V3 copies complete!`);
module.exports = true;