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