fix: preserve yarn releases when cleaning global cache
Previously rm -rf /root/.yarn deleted yarn binary itself. Now only clean cache/telemetry/settings.yml files, keeping releases/ intact.
This commit is contained in:
1 parent
6e1555ab84
commit
8f2cd848e6
1 file changed
+10
-2
+10
-2
@@ -2320,8 +2320,16 @@ def _build_frontend(src_frontend: Path, dest_frontend: Path):
|
|||||||
|
|
||||||
shutil.rmtree(src_frontend / ".yarn", ignore_errors=True)
|
shutil.rmtree(src_frontend / ".yarn", ignore_errors=True)
|
||||||
shutil.rmtree(src_frontend / "node_modules", ignore_errors=True)
|
shutil.rmtree(src_frontend / "node_modules", ignore_errors=True)
|
||||||
# Clean global Yarn 4.x cache with stale patch references
|
# Clean global Yarn 4.x cache with stale patch references (keep yarn releases)
|
||||||
for g in [Path("/root/.yarn"), Path(os.path.expanduser("~/.config/yarn"))]:
|
yarn_global = Path("/root/.yarn")
|
||||||
|
if yarn_global.exists():
|
||||||
|
for d in ["cache", "telemetry", "settings.yml", "yarnrc.yml"]:
|
||||||
|
p = yarn_global / d
|
||||||
|
if p.is_dir():
|
||||||
|
shutil.rmtree(p, ignore_errors=True)
|
||||||
|
elif p.is_file():
|
||||||
|
p.unlink(missing_ok=True)
|
||||||
|
for g in [Path(os.path.expanduser("~/.config/yarn"))]:
|
||||||
if g.exists():
|
if g.exists():
|
||||||
if g.is_dir():
|
if g.is_dir():
|
||||||
shutil.rmtree(g, ignore_errors=True)
|
shutil.rmtree(g, ignore_errors=True)
|
||||||
|
|||||||
Reference in new issue
Block a user