mirror of
https://github.com/spacebarchat/server.git
synced 2026-05-12 21:05:11 +00:00
Better patch system
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
const { execSync } = require("child_process");
|
||||
const path = require("path");
|
||||
const fs = require("fs");
|
||||
const { argv, stdout, exit } = require("process");
|
||||
const { execIn, parts, getDirs, walk, sanitizeVarName } = require("../utils");
|
||||
|
||||
module.exports = function (config) {
|
||||
console.log(`==> Cleaning asset cache...`);
|
||||
const assetDir = path.resolve(path.join(config.rootDir, "assets", "cache"));
|
||||
if (fs.existsSync(assetDir)) {
|
||||
fs.rmSync(assetDir, { recursive: true });
|
||||
if (config.verbose) console.log(`Deleted ${assetDir}!`);
|
||||
}
|
||||
};
|
||||
+14
-2
@@ -3,6 +3,7 @@ const path = require("path");
|
||||
const fs = require("fs");
|
||||
const { argv, stdout, exit } = require("process");
|
||||
const { execIn, parts, getDirs, walk, sanitizeVarName } = require("./utils");
|
||||
const os = require('os');
|
||||
|
||||
//file paths
|
||||
const rootDir = path.join(__dirname, "..");
|
||||
@@ -17,14 +18,25 @@ const pluginDir = path.join(srcDir, "plugins");
|
||||
//more, dont export
|
||||
const buildStepDir = path.join(scriptsDir, "build");
|
||||
|
||||
if (!fs.existsSync(configPath)) {
|
||||
let config;
|
||||
if (fs.existsSync(path.join(rootDir, `build.${os.hostname()}.json`))) {
|
||||
console.log(`Using build.${os.hostname()}.json`);
|
||||
config = { rootDir, srcDir, distDir, configPath, buildLog, buildLogAnsi, pluginDir, ...require(path.join(rootDir, `build.${os.hostname()}.json`)) };
|
||||
}
|
||||
else if (fs.existsSync(configPath)) {
|
||||
console.log(`Using build.json`);
|
||||
config = { rootDir, srcDir, distDir, configPath, buildLog, buildLogAnsi, pluginDir, ...require(configPath) };
|
||||
}
|
||||
else if (!fs.existsSync(configPath)) {
|
||||
console.log(`Using default config`);
|
||||
if (!fs.existsSync(path.join(configPath + ".default"))) {
|
||||
console.log("build.json.default not found! Exiting!");
|
||||
exit(1);
|
||||
}
|
||||
fs.copyFileSync(configPath + ".default", configPath);
|
||||
config = { rootDir, srcDir, distDir, configPath, buildLog, buildLogAnsi, pluginDir, ...require(configPath) };
|
||||
}
|
||||
let config = { rootDir, srcDir, distDir, configPath, buildLog, buildLogAnsi, pluginDir, ...require(configPath) };
|
||||
|
||||
|
||||
config.steps.pre.forEach((step) => require(path.join(buildStepDir, step))(config));
|
||||
require(path.join(buildStepDir, "compile_" + config.compiler))(config);
|
||||
|
||||
Reference in New Issue
Block a user