Deep copy function

This commit is contained in:
msowho 2022-07-18 01:36:54 +05:00
parent 7d3d1ca229
commit 1401d848b2
3 changed files with 5 additions and 7 deletions

View File

@ -9,7 +9,7 @@ import { shortCommit } from "./modules/sub/currentCommit.js";
import { appName, genericUserAgent, version, internetExplorerRedirect } from "./modules/config.js";
import { getJSON } from "./modules/api.js";
import renderPage from "./modules/pageRender.js";
import { apiJSON } from "./modules/sub/utils.js";
import { apiJSON, deepCopy } from "./modules/sub/utils.js";
import loc from "./modules/sub/i18n.js";
import { Bright, Cyan } from "./modules/sub/consoleText.js";
import stream from "./modules/stream/stream.js";
@ -163,11 +163,7 @@ if (fs.existsSync('./.env')) {
buildCSS()
]).then(([js, css]) => {
let currentDistUUID = UUID(),
// TODO: Move deep copy to utils
currentDist = {
uuid: currentDistUUID,
files: JSON.parse(JSON.stringify(css.fontData))
};
currentDist = { uuid: currentDistUUID, files: deepCopy(css.fontData) };
currentDist.files[`bundle.${commitHash}.js`] = js;
currentDist.files[`bundle.${commitHash}.css`] = css.code;

View File

@ -9,7 +9,6 @@ export async function buildJS () {
return transformedJS.code
}
// TODO: Make it work with new fonts
export async function buildCSS () {
let mainCSS = await readFile('./src/static/cobalt.css', { encoding: 'utf-8' }),
fontCSS = await readFile('./src/static/fonts/notosansmono/notosansmono.css', { encoding: 'utf-8' }),

View File

@ -50,3 +50,6 @@ export function cleanURL(url, host) {
}
return url
}
export function deepCopy(object) {
return JSON.parse(JSON.stringify(object))
}