actually fix the build script this time

This commit is contained in:
LimboFPS 2023-09-02 23:27:51 -04:00
parent 1341bba01e
commit 71012ee4c1

View File

@ -7,6 +7,7 @@ const fs = require("fs-extra");
const glob = require("glob"); const glob = require("glob");
const zip = require('bestzip'); const zip = require('bestzip');
const path = require("path"); const path = require("path");
const minimatch = require('minimatch');
// Load the package.json file to get some information about the package so we can name things appropriately. This is // Load the package.json file to get some information about the package so we can name things appropriately. This is
// atypical, and you would never do this in a production environment, but this script is only used for development so // atypical, and you would never do this in a production environment, but this script is only used for development so
@ -40,16 +41,18 @@ const ignoreList = [
"mod.code-workspace", "mod.code-workspace",
"package-lock.json", "package-lock.json",
"tsconfig.json", "tsconfig.json",
"_uabe/" "_uabe/" // Excludes previous .bundle files, so the zip isnt 300MB+
]; ];
const exclude = glob.sync(`{${ignoreList.join(",")}}`, { realpath: true, dot: true }); const exclude = glob.sync(`{${ignoreList.join(",")}}`, { realpath: true, dot: true });
// For some reason these basic-bitch functions won't allow us to copy a directory into itself, so we have to resort to fs.copySync(__dirname, path.normalize(`${__dirname}/../~${modName}`), {filter: (src) =>
// using a temporary directory, like an idiot. Excuse the normalize spam; some modules cross-platform, some don't...
fs.copySync(__dirname, path.normalize(`${__dirname}/../~${modName}`), {filter:(filePath) =>
{ {
return !exclude.includes(filePath); const relativePath = path.relative(__dirname, src);
}}); const shouldExclude = exclude.some((pattern) => minimatch(relativePath, pattern));
console.log(`${relativePath} - Excluded: ${shouldExclude}`);
return !shouldExclude;
},});
fs.moveSync(path.normalize(`${__dirname}/../~${modName}`), path.normalize(`${__dirname}/${modName}`), { overwrite: true }); fs.moveSync(path.normalize(`${__dirname}/../~${modName}`), path.normalize(`${__dirname}/${modName}`), { overwrite: true });
fs.copySync(path.normalize(`${__dirname}/${modName}`), path.normalize(`${__dirname}/dist`)); fs.copySync(path.normalize(`${__dirname}/${modName}`), path.normalize(`${__dirname}/dist`));
console.log("Build files copied."); console.log("Build files copied.");