2021-10-23 10:38:52 -04:00
|
|
|
/* eslint-disable */
|
|
|
|
const { copy, remove, access } = require("fs-extra");
|
|
|
|
const { exec: cexec } = require("child_process");
|
|
|
|
const { resolve } = require("path");
|
|
|
|
|
|
|
|
let target = process.env.REVOLT_SASS;
|
2021-10-23 11:00:20 -04:00
|
|
|
let branch = process.env.REVOLT_SASS_BRANCH;
|
2021-10-23 10:38:52 -04:00
|
|
|
let DEFAULT_DIRECTORY = "public/assets_default";
|
|
|
|
let OUT_DIRECTORY = "public/assets";
|
|
|
|
|
|
|
|
function exec(command) {
|
|
|
|
return new Promise((fulfil, reject) => {
|
|
|
|
cexec(command, (err, stdout, stderr) => {
|
|
|
|
if (err) {
|
|
|
|
reject(err);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
fulfil({ stdout, stderr });
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
(async () => {
|
|
|
|
try {
|
|
|
|
await access(OUT_DIRECTORY);
|
|
|
|
if (process.argv[2] === "--check") return;
|
|
|
|
|
|
|
|
await remove(OUT_DIRECTORY);
|
|
|
|
} catch (err) {}
|
|
|
|
|
|
|
|
if (target) {
|
2021-10-23 11:04:23 -04:00
|
|
|
let arg = branch ? `-b ${branch} ` : "";
|
2021-10-23 11:00:20 -04:00
|
|
|
await exec(`git clone ${arg}${target} ${OUT_DIRECTORY}`);
|
2021-10-23 10:38:52 -04:00
|
|
|
await exec(`rm -rf ${resolve(OUT_DIRECTORY, ".git")}`);
|
|
|
|
} else {
|
|
|
|
await copy(DEFAULT_DIRECTORY, OUT_DIRECTORY);
|
|
|
|
}
|
|
|
|
})();
|