forked from krausest/js-framework-benchmark
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigureStyles.js
55 lines (47 loc) · 1.57 KB
/
configureStyles.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
const fs = require("fs-extra");
const yargs = require("yargs");
const path = require("path");
const args = yargs(process.argv)
.usage("$0 [--bootstrap --minimal]")
.help("help")
.boolean("bootstrap")
.default("bootstrap", false)
.boolean("minimal")
.default("minimal", false).argv;
// Function to copy CSS and generate shared-styles.html
async function copyAndGenerateSharedStyles(sourceCss, mainCss) {
await fs.copy(sourceCss, path.join("css", "currentStyle.css"));
// Read the main CSS file
const mainCssContent = await fs.readFile(mainCss, "utf8");
// Generate shared-styles.html content
const sharedStylesContent = `<dom-module id="shared-styles"><template><style>${mainCssContent}</style></template></dom-module>`;
// Write shared-styles.html
await fs.writeFile(
path.join("polymer-v2.0.0-non-keyed", "src", "shared-styles.html"),
sharedStylesContent
);
}
// Main function
async function configureStyles() {
try {
if (args.bootstrap ^ args.minimal) {
console.log("ERROR: You must either choose bootstrap or minimal");
return;
}
// Read and copy the appropriate CSS file
if (args.bootstrap) {
await copyAndGenerateSharedStyles(
path.join("css", "useOriginalBootstrap.css"),
path.join("css", "bootstrap", "dist", "css", "bootstrap.min.css")
);
} else {
await copyAndGenerateSharedStyles(
path.join("css", "useMinimalCss.css"),
path.join("css", "useMinimalCss.css")
);
}
} catch (error) {
console.error("An error occurred:", error.message);
}
}
configureStyles();