@modjo/core
Advanced tools
Comparing version 1.4.0 to 1.4.1
@@ -42,7 +42,7 @@ const path = require("path") | ||
function buildDirTree(treeDirs) { | ||
function buildDirTree(treeDirs, { filter } = {}) { | ||
for (const { dir, pattern, dirName } of treeDirs) { | ||
const dirPath = path.resolve(srcDir, dir) | ||
const content = fs.existsSync(dirPath) | ||
? dirtree2static(dirPath, { pattern, loader: treeFileLoader }) | ||
? dirtree2static(dirPath, { pattern, loader: treeFileLoader, filter }) | ||
: JSON.stringify({}) | ||
@@ -49,0 +49,0 @@ const dest = path.join(buildDir, `${dirName || dir}.js`) |
{ | ||
"name": "@modjo/core", | ||
"version": "1.4.0", | ||
"version": "1.4.1", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "dependencies": { |
@@ -31,15 +31,18 @@ const fs = require("fs") | ||
} | ||
const { pattern, loader } = options | ||
const { pattern, loader, filter = () => true } = options | ||
const stats = fs.lstatSync(filename) | ||
if (stats.isDirectory()) { | ||
const files = fs.readdirSync(filename).filter((file) => { | ||
const absPath = `${filename}/${file}` | ||
const relPath = absPath.slice(rootDir.length) | ||
return ( | ||
(typeof pattern === "function" | ||
? pattern(relPath) | ||
: relPath.match(pattern)) || | ||
fs.lstatSync(`${filename}/${file}`).isDirectory() | ||
) | ||
}) | ||
const files = fs | ||
.readdirSync(filename) | ||
.filter(filter) | ||
.filter((file) => { | ||
const absPath = `${filename}/${file}` | ||
const relPath = absPath.slice(rootDir.length) | ||
return ( | ||
(typeof pattern === "function" | ||
? pattern(relPath) | ||
: relPath.match(pattern)) || | ||
fs.lstatSync(`${filename}/${file}`).isDirectory() | ||
) | ||
}) | ||
@@ -46,0 +49,0 @@ const results = {} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22076
735