UNPKG

resolve-tspaths

Version:

Transform path mappings in your compiled Typescript code

25 lines (24 loc) 901 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getFilesToProcess = getFilesToProcess; const path_1 = require("path"); const fast_glob_1 = require("fast-glob"); const path_2 = require("../utils/path"); /** * Get the files in the output directory that should be processed. * * @param outPath The output directory. * @param extensions A list of extensions to match. */ function getFilesToProcess(outPath, extensions) { const normalizedOutPath = (0, fast_glob_1.convertPathToPattern)((0, path_2.normalizePath)(outPath)); let glob = "*"; if (extensions.length === 1) glob = `*.${extensions[0]}`; else if (extensions.length > 1) glob = `*.{${extensions.join(",")}}`; return (0, fast_glob_1.sync)(`${normalizedOutPath}/**/${glob}`, { dot: true, onlyFiles: true, }).map((path) => (0, path_1.resolve)(path)); }