From 18e91d1acf53d125d71ace79bf6b654bc767a6a5 Mon Sep 17 00:00:00 2001 From: "Daniel D. Beck" Date: Mon, 16 Sep 2024 14:29:52 +0200 Subject: [PATCH 1/2] `update-drafts`: delete completed specs --- .../workflows/update_draft_features_weekly.yml | 1 - scripts/update-drafts.ts | 18 +++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/.github/workflows/update_draft_features_weekly.yml b/.github/workflows/update_draft_features_weekly.yml index 62caf966693..e9cc3cb8aed 100644 --- a/.github/workflows/update_draft_features_weekly.yml +++ b/.github/workflows/update_draft_features_weekly.yml @@ -16,7 +16,6 @@ jobs: node-version-file: .node-version cache: npm - run: npm ci - - run: git rm features/draft/spec/*.yml features/draft/spec/*.dist - run: npm run update-drafts - run: npm run dist - name: Create pull request diff --git a/scripts/update-drafts.ts b/scripts/update-drafts.ts index c25f4c737e3..50b196c57a6 100644 --- a/scripts/update-drafts.ts +++ b/scripts/update-drafts.ts @@ -172,14 +172,23 @@ async function main() { } } - // If all features are already part of web-features, skip this spec. + const id = formatIdentifier(spec.shortname); + const destination = `features/draft/spec/${id}.yml`; + + // If all features are already part of web-features if (compatFeatures.size === 0) { + try { + const dist = `${destination}.dist`; + await fs.rm(destination); + logger.warn(`${destination}: deleted`); + await fs.rm(dist); + logger.warn(`${dist}: deleted`); + } catch (err) { + // If deleting fails, it probably didn't exist in the first place + } continue; } - // Write out draft feature per spec. - const id = formatIdentifier(spec.shortname); - const feature = new Document({ draft_date: new Date().toISOString().substring(0, 10), name: spec.title, @@ -197,7 +206,6 @@ async function main() { feature.comment = usedFeaturesComment.trimEnd(); } - const destination = `features/draft/spec/${id}.yml`; const proposedFile = feature.toString(); let originalFile: string; From 8691e54c806e75b5c22384af40aa605d8ee2160b Mon Sep 17 00:00:00 2001 From: "Daniel D. Beck" Date: Tue, 17 Sep 2024 16:57:34 +0200 Subject: [PATCH 2/2] Make deletion failures more explicit --- scripts/update-drafts.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/scripts/update-drafts.ts b/scripts/update-drafts.ts index 50b196c57a6..a166e242739 100644 --- a/scripts/update-drafts.ts +++ b/scripts/update-drafts.ts @@ -177,14 +177,18 @@ async function main() { // If all features are already part of web-features if (compatFeatures.size === 0) { + const dist = `${destination}.dist`; try { - const dist = `${destination}.dist`; await fs.rm(destination); logger.warn(`${destination}: deleted`); + } catch (error) { + logger.debug(`${destination}: deletion failed`); + } + try { await fs.rm(dist); logger.warn(`${dist}: deleted`); - } catch (err) { - // If deleting fails, it probably didn't exist in the first place + } catch (error) { + logger.debug(`${dist}: deletion failed`); } continue; }