Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

547 B
Raw Blame
const { readFileSync } = require("node:fs");

/**
 * @param {string | undefined} pathsFile
 * @returns {string[] | null} null when no paths file is given
 */
function readSpecPaths(pathsFile) {
  if (!pathsFile) {
    return null;
  }

  const files = JSON.parse(readFileSync(pathsFile, "utf8"));
  if (
    !Array.isArray(files) ||
    !files.every((file) => typeof file === "string" && file.length > 0)
  ) {
    throw new Error("Spec paths must be a JSON array of non-empty strings");
  }
  return files;
}

module.exports = { readSpecPaths };