@@ -64476,6 +64476,7 @@ async function getCmdOutput(cmd, args = [], options = {}) {
6447664476;// CONCATENATED MODULE: ./src/workspace.ts
6447764477
6447864478
64479+
6447964480const SAVE_TARGETS = new Set(["lib", "proc-macro"]);
6448064481class Workspace {
6448164482 constructor(root, target) {
@@ -64485,9 +64486,11 @@ class Workspace {
6448564486 async getPackages() {
6448664487 let packages = [];
6448764488 try {
64489+ lib_core.debug(`collecting metadata for "${this.root}"`);
6448864490 const meta = JSON.parse(await getCmdOutput("cargo", ["metadata", "--all-features", "--format-version", "1"], {
6448964491 cwd: this.root,
6449064492 }));
64493+ lib_core.debug(`workspace "${this.root}" has ${meta.packages.length} packages`);
6449164494 for (const pkg of meta.packages) {
6449264495 if (pkg.manifest_path.startsWith(this.root)) {
6449364496 continue;
@@ -64840,30 +64843,34 @@ async function cleanGit(packages) {
6484064843}
6484164844const ONE_WEEK = 7 * 24 * 3600 * 1000;
6484264845/**
64843- * Removes all files or directories in `dirName`, except the ones matching
64844- * any string in the `keepPrefix` set.
64845- *
64846- * The matching strips and trailing `-$hash` suffix.
64846+ * Removes all files or directories in `dirName` matching some criteria.
6484764847 *
6484864848 * When the `checkTimestamp` flag is set, this will also remove anything older
6484964849 * than one week.
64850+ *
64851+ * Otherwise, it will remove everything that does not match any string in the
64852+ * `keepPrefix` set.
64853+ * The matching strips and trailing `-$hash` suffix.
6485064854 */
6485164855async function rmExcept(dirName, keepPrefix, checkTimestamp = false) {
6485264856 const dir = await external_fs_default().promises.opendir(dirName);
6485364857 for await (const dirent of dir) {
64858+ if (checkTimestamp) {
64859+ const fileName = external_path_default().join(dir.path, dirent.name);
64860+ const { mtime } = await external_fs_default().promises.stat(fileName);
64861+ const isOutdated = Date.now() - mtime.getTime() > ONE_WEEK;
64862+ if (isOutdated) {
64863+ await rm(dir.path, dirent);
64864+ }
64865+ return;
64866+ }
6485464867 let name = dirent.name;
6485564868 // strip the trailing hash
6485664869 const idx = name.lastIndexOf("-");
6485764870 if (idx !== -1) {
6485864871 name = name.slice(0, idx);
6485964872 }
64860- let isOutdated = false;
64861- if (checkTimestamp) {
64862- const fileName = external_path_default().join(dir.path, dirent.name);
64863- const { mtime } = await external_fs_default().promises.stat(fileName);
64864- isOutdated = Date.now() - mtime.getTime() > ONE_WEEK;
64865- }
64866- if (!keepPrefix.has(name) || isOutdated) {
64873+ if (!keepPrefix.has(name)) {
6486764874 await rm(dir.path, dirent);
6486864875 }
6486964876 }
@@ -64933,8 +64940,7 @@ async function run() {
6493364940 // pre-clean the target directory on cache mismatch
6493464941 for (const workspace of config.workspaces) {
6493564942 try {
64936- const packages = await workspace.getPackages();
64937- await cleanTargetDir(workspace.target, packages, true);
64943+ await cleanTargetDir(workspace.target, [], true);
6493864944 }
6493964945 catch { }
6494064946 }
0 commit comments