mirror of
https://github.com/WeBankFinTech/fes.js.git
synced 2025-06-29 10:04:44 +08:00
refactor: 优化清理代码
This commit is contained in:
parent
3c5113ce74
commit
b926ae87ec
@ -8,19 +8,17 @@ const path = require('path');
|
|||||||
|
|
||||||
async function handleCacheClean(cwd) {
|
async function handleCacheClean(cwd) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const cachePath = path.join(cwd, '.cache');
|
const cachePath = path.join(cwd, '.cache/webpack');
|
||||||
require('get-folder-size')(cachePath, (err, size) => {
|
require('get-folder-size')(cachePath, (err, size) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
reject(err);
|
return reject(err);
|
||||||
} else {
|
}
|
||||||
// 大于 5G 清除缓存,修复 webpack 缓存无限增长问题
|
// 大于 5G 清除缓存,修复 webpack 缓存无限增长问题
|
||||||
// https://github.com/webpack/webpack/issues/13291
|
// https://github.com/webpack/webpack/issues/13291
|
||||||
size = (size / 1024 / 1024 / 1024).toFixed(2);
|
if (size > 5 * 1024 * 1024 * 1024) {
|
||||||
if (size > 5) {
|
|
||||||
require('fs-extra').removeSync(cachePath);
|
require('fs-extra').removeSync(cachePath);
|
||||||
}
|
}
|
||||||
resolve(size);
|
resolve(size);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user