webpack/test/helpers/findOutputFiles.js

19 lines
482 B
JavaScript
Raw Normal View History

2021-11-29 20:37:38 +08:00
"use strict";
const fs = require("fs");
const path = require("path");
/**
* @param {{output: {path: string}}} options options
* @param {RegExp} regexp regexp
* @param {string=} subpath path in output directory
* @returns {string[]} files
*/
module.exports = function findOutputFiles(options, regexp, subpath) {
const files = fs.readdirSync(
subpath ? path.join(options.output.path, subpath) : options.output.path
);
return files.filter((file) => regexp.test(file));
2021-11-29 20:37:38 +08:00
};