-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
40 lines (36 loc) · 1.16 KB
/
index.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
import { exec } from "child_process";
import fs from "fs";
import path from "path";
import { fileURLToPath } from "url";
// fixes ReferenceError: __dirname is not defined in ES module scope
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const themeConverterPath = process.env.THEME_CONVERTER_PATH;
const themePath = path.join(__dirname, "vscode-themes");
const outputPath = path.join(__dirname, "Learn With Sumit Theme (Unofficial)");
fs.readdir(themePath, (err, files) => {
if (err) {
return console.log("Unable to scan directory: " + err);
}
files.forEach((file) => {
if (file.endsWith(".json")) {
const filePath = path.join(themePath, file);
setTimeout(() => {
exec(
`cd ${themeConverterPath} && ThemeConverter.exe -i "${filePath.toString()}" -o "${outputPath.toString()}"`,
(err, stdout, stderr) => {
if (err) {
console.error(err);
}
if (stdout) {
console.log(stdout);
}
if (stderr) {
console.error(stderr);
}
}
);
}, 1000);
}
});
});