From 4407cd23800982b412c163dc666e3523cdc4128e Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Thu, 7 Oct 2021 20:11:04 +0300 Subject: [PATCH] Create file.js --- scripts/file.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 scripts/file.js diff --git a/scripts/file.js b/scripts/file.js new file mode 100644 index 00000000..1dc85205 --- /dev/null +++ b/scripts/file.js @@ -0,0 +1,23 @@ +const glob = require('glob') + +function list(include = [], exclude = []) { + return new Promise(resolve => { + glob('channels/**/*.xml', function (err, files) { + if (include.length) { + include = include.map(filename => `channels/${filename}.xml`) + files = files.filter(filename => include.includes(filename)) + } + + if (exclude.length) { + exclude = exclude.map(filename => `channels/${filename}.xml`) + files = files.filter(filename => !exclude.includes(filename)) + } + + resolve(files) + }) + }) +} + +module.exports = { + list +}