-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsass-json-handler.js
More file actions
50 lines (45 loc) · 1.66 KB
/
sass-json-handler.js
File metadata and controls
50 lines (45 loc) · 1.66 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
// Due to the typescript compiler not copying scss files
// and making them empty files the output end up being bad
const fs = require("fs");
const path = require("path");
function walkDirectory(directory, targetDirectory) {
fs.readdir(directory, (err, list) => {
if (err) {
throw err;
}
list.forEach((filename) => {
const filepath = path.resolve(directory, filename);
const outFilePath = path.resolve(targetDirectory, filename);
if (filename.endsWith(".scss") || filename.endsWith(".sass") || filename.endsWith(".css") || filename.endsWith(".json")) {
console.log("outputting", outFilePath);
if (filename.endsWith(".json")) {
const content = fs.readFileSync(filepath, "utf-8");
fs.writeFile(outFilePath, content, () => {});
} else {
fs.writeFile(outFilePath, "", () => {});
}
} else {
fs.stat(filepath, (err, stat) => {
if (stat && stat.isDirectory()) {
fs.exists(outFilePath, (doesExist) => {
if (!doesExist) {
console.log("making", outFilePath);
fs.mkdir(outFilePath, (err) => {
if (err) {
throw err;
}
walkDirectory(filepath, outFilePath);
})
} else {
walkDirectory(filepath, outFilePath);
}
});
}
});
}
});
});
}
// corruption that occurs during the npm install process with forgets these files
walkDirectory("imported-resources", path.join("nodejs", "imported-resources"));
walkDirectory("client", path.join("nodejs", "client"));