diff --git a/features/draft/html-elements/README.md b/features/draft/html-elements/README.md
index 14ef9c1dcdf..daa2591f9f8 100644
--- a/features/draft/html-elements/README.md
+++ b/features/draft/html-elements/README.md
@@ -9,9 +9,7 @@ To help out, pick a feature and do the following:
its own feature or if it should be grouped with other features.
- Review `baseline_low_date`, does it look plausible? If not, remove features
from `compat_features` until the date and browser versions seem plausible. Run
- `npm run dist features/draft/html-elements/tag.yml` to regenerate dist. If
- this throws an error, most likely BCD needs to be updated first to provide
- better data.
+ `npm run dist features/draft/html-elements` to regenerate dist.
- Write a description for the feature.
- Move the file into the main features/ directory and submit a PR with your
changes.
diff --git a/package.json b/package.json
index e2b07bf9fe9..d7436d74d86 100644
--- a/package.json
+++ b/package.json
@@ -22,7 +22,7 @@
"schema-defs:write": "npm run schema-defs -- --out ./schemas/defs.schema.json",
"test": "npm run test:caniuse -- --quiet && npm run test:schema && npm run test:specs && npm run test:format && npm run test:dist && npm run test --workspaces",
"test:caniuse": "tsx scripts/caniuse.ts",
- "test:dist": "tsx scripts/dist.ts --check features/**/*.yml.dist",
+ "test:dist": "tsx scripts/dist.ts --check",
"test:schema": "tsx scripts/schema.ts",
"test:specs": "tsx scripts/specs.ts",
"test:format": "prettier --check .",
diff --git a/scripts/dist.ts b/scripts/dist.ts
index e9d7999de8f..23cfe47e5b0 100644
--- a/scripts/dist.ts
+++ b/scripts/dist.ts
@@ -8,15 +8,16 @@ import { isDeepStrictEqual } from "node:util";
import winston from "winston";
import YAML, { Document } from "yaml";
import yargs from "yargs";
+import { fdir } from "fdir";
const argv = yargs(process.argv.slice(2))
.scriptName("dist")
- .usage("$0 [filenames..]", "Generate .yml.dist from .yml", (yargs) =>
- yargs.positional("filenames", {
- describe: "YAML files to check/update.",
+ .usage("$0 [paths..]", "Generate .yml.dist from .yml", (yargs) =>
+ yargs.positional("paths", {
+ describe: "Directories or files to check/update.",
+ default: ["features"],
}),
)
- .demandOption("filenames")
.option("check", {
boolean: true,
default: false,
@@ -208,16 +209,29 @@ function warnOnNeedlessOverrides(id, overridden, generated) {
}
function main() {
+ const filePaths = argv.paths.flatMap((fileOrDirectory) => {
+ if (fs.statSync(fileOrDirectory).isDirectory()) {
+ // Expand directory to any existing .dist file within.
+ // TODO: Change this to .yml when all features have dist files.
+ return new fdir()
+ .withBasePath()
+ .filter((fp) => fp.endsWith(".dist"))
+ .crawl(fileOrDirectory)
+ .sync();
+ }
+ return fileOrDirectory;
+ });
+
// Map from .yml to .yml.dist to filter out duplicates.
const sourceToDist = new Map(
- argv.filenames.map((filePath: string) => {
+ filePaths.map((filePath: string) => {
const ext = path.extname(filePath);
if (![".dist", ".yml"].includes(ext)) {
throw new Error(
`Cannot generate dist for ${filePath}, only YAML input is supported`,
);
}
- // Start from the source even if dist is given
+ // Start from the source even if dist is given.
if (filePath.endsWith(".dist")) {
const candidateFilePath = filePath.substring(0, filePath.length - 5);