mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
修复katex角标漂移等问题
This commit is contained in:
1 parent
1f1efe900c
commit
a248425db6
17 files changed
+491
-235
No files matched your search
@@ -1,3 +1,5 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const superagent = require('superagent');
|
||||
const proxy = require('superagent-proxy');
|
||||
|
||||
@@ -72,3 +74,33 @@ Set.intersection = function Intersection(setA, setB) {
|
||||
}
|
||||
return intersection;
|
||||
};
|
||||
|
||||
/**
|
||||
* calculate size of a file or directory synchronously
|
||||
* @param {String} folderPath path of the file or folder
|
||||
* @param {fsizeOptions} opts additional options
|
||||
* @returns {Number}
|
||||
*/
|
||||
function folderSize(folderPath) {
|
||||
let size = 0;
|
||||
const _next = function a(p) {
|
||||
if (p) {
|
||||
const stats = fs.statSync(p);
|
||||
if (!stats.isDirectory() || stats.isSymbolicLink()) {
|
||||
if (!stats.isSymbolicLink()) size += stats.size;
|
||||
} else {
|
||||
size += stats.size;
|
||||
const files = fs.readdirSync(p);
|
||||
if (Array.isArray(files)) {
|
||||
files.forEach((file) => {
|
||||
_next(path.join(p, file));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
_next(folderPath);
|
||||
return size;
|
||||
}
|
||||
|
||||
exports.folderSize = folderSize;
|
||||
Reference in new issue
Block a user