@uswds/tokens
Version:
Collection of USWDS tokens for use across projects
16 lines (14 loc) • 492 B
JavaScript
import { readdirSync } from "fs";
import path from "path";
/**
* Returns an array of token JSON file names (without extensions) from a specified directory.
*
* @param {string} dir - Directory of token JSON files.
* @returns {Array} An array of token file names without extensions.
*/
export const getFileNames = (dir) => {
const dirPath = path.resolve(dir);
return readdirSync(dirPath)
.filter((file) => file.endsWith(".json"))
.map((file) => file.replace(".json", ""));
}