Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
impl: (interpreter: Interpreter, pathArg: BrsString, patternIn: BrsString) => {
let volume = getVolumeByPath(interpreter, pathArg.value);
if (volume == null) {
// TODO: replace with RoList when that's implemented
return new RoArray([]);
}
let localPath = path.join(interpreter.options.root, getPath(pathArg.value));
try {
let knownFiles = fs.readdirSync(localPath, "utf8");
let matchedFiles = nanomatch.match(knownFiles, patternIn.value, {
nocase: true,
nodupes: true,
noglobstar: true,
nonegate: true,
});
matchedFiles = (matchedFiles || []).map((match: string) => new BrsString(match));
// TODO: replace with RoList when that's implemented
return new RoArray(matchedFiles);
} catch (err) {
// TODO: replace with RoList when that's implemented
return new RoArray([]);
}
},
});
module.exports = function(files, pattern) {
return nanomatch.match(files, pattern);
};