Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions scripts/dist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,16 +353,33 @@ const tagsToFeatures: Map<string, Feature[]> = (() => {
return map;
})();

/**
* Check if a file is an authored definition or dist file. Throws on likely
* mistakes, such as `.yaml` files.
*/
function isDistOrDistable(path: string): boolean {
if (path.endsWith(".yaml.dist") || path.endsWith(".yaml")) {
throw new Error(
`YAML files must use .yml extension; ${path} has invalid extension`,
);
}
if (path.endsWith(".yml.dist") || path.endsWith(".yml")) {
return true;
}
logger.debug(`${path} is not a likely YAML file, skipping`);
return false;
}

function main() {
const filePaths = argv.paths.flatMap((fileOrDirectory) => {
const filePaths: string[] = argv.paths.flatMap((fileOrDirectory) => {
if (fs.statSync(fileOrDirectory).isDirectory()) {
return new fdir()
.withBasePath()
.filter((fp) => !(fp.endsWith(".md") || fp.endsWith(".DS_Store")))
.filter(isDistOrDistable)
.crawl(fileOrDirectory)
.sync();
}
return fileOrDirectory;
return isDistOrDistable(fileOrDirectory) ? fileOrDirectory : [];
});

// Map from .yml to .yml.dist to filter out duplicates.
Expand Down