rename fina -> filePath in load_var
This commit is contained in:
parent
d44d107304
commit
12e2fa914f
@ -1,5 +1,5 @@
|
|||||||
import ejs from "ejs"
|
import ejs from "ejs"
|
||||||
import LRU from "lru-cache"
|
import { LRUCache as LRU} from "lru-cache"
|
||||||
import {minify as min_js} from "uglify-js"
|
import {minify as min_js} from "uglify-js"
|
||||||
import Clean from 'clean-css';
|
import Clean from 'clean-css';
|
||||||
import Minifier from 'html-minifier-terser';
|
import Minifier from 'html-minifier-terser';
|
||||||
@ -25,27 +25,27 @@ export const setup = function (router, con, server) {
|
|||||||
updateAgeOnHas: true
|
updateAgeOnHas: true
|
||||||
})
|
})
|
||||||
|
|
||||||
function load_var(fina) {
|
function load_var(filePath) {
|
||||||
if(load_var_cache.get(fina))return load_var_cache.get(fina)
|
if (load_var_cache.has(filePath)) {
|
||||||
if(!existsSync(fina)) {
|
return load_var_cache.get(filePath);
|
||||||
console.log(1,"tried loading non-existent file",fina)
|
|
||||||
load_var_cache.set(fina,"")
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
let out = readFileSync(fina)
|
|
||||||
if(fina.endsWith(".js")) {
|
|
||||||
out = min_js(out.toString()).code
|
|
||||||
}
|
|
||||||
else if(fina.endsWith(".css")) {
|
|
||||||
const {
|
|
||||||
styles,
|
|
||||||
} = new Clean({}).minify(out.toString());
|
|
||||||
out = styles
|
|
||||||
}
|
}
|
||||||
|
|
||||||
load_var_cache.set(fina,out)
|
if (!existsSync(filePath)) {
|
||||||
|
console.log(1,'Tried loading non-existent file', filePath);
|
||||||
|
load_var_cache.set(filePath, '');
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
return out
|
let output = readFileSync(filePath);
|
||||||
|
|
||||||
|
if (filePath.endsWith('.js')) {
|
||||||
|
output = min_js(output.toString()).code;
|
||||||
|
} else if (filePath.endsWith('.css')) {
|
||||||
|
const { styles } = new Clean({}).minify(output.toString());
|
||||||
|
output = styles;
|
||||||
|
}
|
||||||
|
load_var_cache.set(filePath, output);
|
||||||
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_channels(){
|
function get_channels(){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user