diff options
author | The Arcane Brony <myrainbowdash949@gmail.com> | 2021-12-21 11:56:33 +0100 |
---|---|---|
committer | The Arcane Brony <myrainbowdash949@gmail.com> | 2021-12-21 11:56:33 +0100 |
commit | d0cd5b7040445447beb3057e0b0332c2ab109cdb (patch) | |
tree | 7513577b1b796095f7ba2c39fc22c9563a1b9128 /bundle/scripts | |
parent | Fix people not being able to create issues (diff) | |
download | server-d0cd5b7040445447beb3057e0b0332c2ab109cdb.tar.xz |
Repo cleanup, remove fs-extras
Diffstat (limited to 'bundle/scripts')
-rw-r--r-- | bundle/scripts/build.js | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/bundle/scripts/build.js b/bundle/scripts/build.js index 88d76d34..4f56694c 100644 --- a/bundle/scripts/build.js +++ b/bundle/scripts/build.js @@ -1,6 +1,7 @@ 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"); @@ -8,21 +9,41 @@ const dirs = ["api", "util", "cdn", "gateway", "bundle"]; const verbose = argv.includes("verbose") || argv.includes("v"); +var copyRecursiveSync = function(src, dest) { + if(verbose) console.log(`cpsync: ${src} -> ${dest}`); + var exists = fs.existsSync(src); + if(!exists){ + console.log(src + " doesn't exist, not copying!"); + return; + } + var stats = exists && fs.statSync(src); + var isDirectory = exists && stats.isDirectory(); + if (isDirectory) { + fs.mkdirSync(dest, {recursive: true}); + fs.readdirSync(src).forEach(function(childItemName) { + copyRecursiveSync(path.join(src, childItemName), + path.join(dest, childItemName)); + }); + } else { + fs.copyFileSync(src, dest); + } + }; + if (argv.includes("clean")) { dirs.forEach((a) => { var d = "../" + a + "/dist"; - if (fse.existsSync(d)) { - fse.rmSync(d, { recursive: true }); + if (fs.existsSync(d)) { + fs.rmSync(d, { recursive: true }); if (verbose) console.log(`Deleted ${d}!`); } }); } -fse.copySync(path.join(__dirname, "..", "..", "api", "assets"), path.join(__dirname, "..", "dist", "api", "assets")); -fse.copySync(path.join(__dirname, "..", "..", "api", "client_test"), path.join(__dirname, "..", "dist", "api", "client_test")); -fse.copySync(path.join(__dirname, "..", "..", "api", "locales"), path.join(__dirname, "..", "dist", "api", "locales")); +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")); dirs.forEach((a) => { - fse.copySync("../" + a + "/src", "dist/" + a + "/src"); + copyRecursiveSync("../" + a + "/src", "dist/" + a + "/src"); if (verbose) console.log(`Copied ${"../" + a + "/dist"} -> ${"dist/" + a + "/src"}!`); }); @@ -46,3 +67,4 @@ if (!argv.includes("copyonly")) { ) ); } + |