nunjucks-template-loader
Version:
Webpack loader for Nunjucks
34 lines (29 loc) • 740 B
JavaScript
const glob = require('glob');
const fs = require('fs');
const path = require('path');
/**
* Generate pathes
* @param {string} matches
*/
function getFiles(matches) {
try {
const pathes = glob.sync(matches);
const folders = [];
const files = [];
pathes.forEach(file => {
if (fs.statSync(file).isDirectory()) {
folders.push({
[]: file
});
} else if (fs.statSync(file).isFile()) {
files.push({
[]: file
});
}
})
return {folders, files};
} catch (e) {
throw e;
}
}
module.exports = getFiles