-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpostInstall.js
More file actions
33 lines (28 loc) · 978 Bytes
/
postInstall.js
File metadata and controls
33 lines (28 loc) · 978 Bytes
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
const fs = require("fs");
const { execSync } = require("child_process");
const removeDirectorySync = (path) => {
if (fs.existsSync(path)) {
const files = fs.readdirSync(path);
files.forEach((file) => {
const curPath = path + "/" + file;
if (fs.lstatSync(curPath).isDirectory()) {
removeDirectorySync(curPath); // Recursive call for subdirectories
} else {
fs.unlinkSync(curPath); // Delete files
}
});
fs.rmdirSync(path); // Remove the empty directory
}
};
const run = () => {
if (!process.env.GITHUB_ACTIONS) {
if (fs.existsSync("sites")) {
removeDirectorySync("sites");
}
console.log("Waiting 10 seconds...."); // If someone figures out how to disable the git filter-branch warning, let us know
execSync(
"git clone https://github.com/peviitor-ro/scrapers.js.git sites && cd sites && git filter-branch --prune-empty --subdirectory-filter sites HEAD && cd ../"
);
}
};
run();