1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-10 04:32:35 +01:00

Improve build scripts, strip more fs-extras

This commit is contained in:
The Arcane Brony 2021-12-21 20:49:58 +00:00
parent d0cd5b7040
commit cbd337701f
3 changed files with 9 additions and 6 deletions

View File

@ -1,10 +1,12 @@
const { execSync } = require("child_process");
const path = require("path");
const fse = require("fs-extra");
const fs = require("fs");
const { getSystemErrorMap } = require("util");
const { argv } = require("process");
var steps = 2, i = 0;
if (argv.includes("clean")) steps++;
if (argv.includes("copyonly")) steps--;
const dirs = ["api", "util", "cdn", "gateway", "bundle"];
const verbose = argv.includes("verbose") || argv.includes("v");
@ -30,6 +32,7 @@ var copyRecursiveSync = function(src, dest) {
};
if (argv.includes("clean")) {
console.log(`[${++i}/${steps}] Cleaning...`);
dirs.forEach((a) => {
var d = "../" + a + "/dist";
if (fs.existsSync(d)) {
@ -39,6 +42,7 @@ if (argv.includes("clean")) {
});
}
console.log(`[${++i}/${steps}] Copying src files...`);
copyRecursiveSync(path.join(__dirname, "..", "..", "api", "assets"), path.join(__dirname, "..", "dist", "api", "assets"));
copyRecursiveSync(path.join(__dirname, "..", "..", "api", "client_test"), path.join(__dirname, "..", "dist", "api", "client_test"));
copyRecursiveSync(path.join(__dirname, "..", "..", "api", "locales"), path.join(__dirname, "..", "dist", "api", "locales"));
@ -47,9 +51,8 @@ dirs.forEach((a) => {
if (verbose) console.log(`Copied ${"../" + a + "/dist"} -> ${"dist/" + a + "/src"}!`);
});
console.log("[1/2] Copying src files done");
if (!argv.includes("copyonly")) {
console.log("[2/2] Compiling src files ...");
console.log(`[${++i}/${steps}] Compiling src files ...`);
console.log(
execSync(

View File

@ -43,7 +43,7 @@ Commit Hash: ${
? `${cyan(commit)} (${yellow(commit.slice(0, 7))})`
: "Unknown (Git cannot be found)"
}
Cores: ${cyan(cores)}
Cores: ${cyan(os.cpus().length)} (Using ${cores} thread(s).)
`)
);

View File

@ -1,6 +1,6 @@
const dotenv = require("dotenv");
const path = require("path");
const fse = require("fs-extra");
const fs = require("fs");
dotenv.config();
// TODO: write unittest to check if FileStorage.ts is working
@ -21,7 +21,7 @@ if (process.env.STORAGE_PROVIDER === "file") {
} else {
process.env.STORAGE_LOCATION = path.join(__dirname, "..", "files", "/");
}
fse.ensureDirSync(process.env.STORAGE_LOCATION);
if(!fs.existsSync(process.env.STORAGE_LOCATION)) fs.mkdirSync(process.env.STORAGE_LOCATION, {recursive:true});
}
const { CDNServer } = require("../dist/Server");
const { Config } = require("@fosscord/util");