New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add missing functionality for glob compatibility #279
Comments
Regex support is WIP here: https://github.com/blackflux/object-scan/pull/1247/files |
This might not be that hard actually: const isEqual = require('lodash.isequal');
const fs = require('smart-fs');
const path = require('path');
const objectScan = require('object-scan');
const list = (needles, folder) => objectScan(needles, {
breakFn: ({ key, value, isMatch, context }) => {
const p = path.join(folder, ...key);
const stats = fs.lstatSync(p);
const isDir = stats.isDirectory();
const isFile = stats.isFile();
if (isDir) {
fs.readdirSync(p).forEach((f) => {
value[f] = {};
});
} else if (isFile && isMatch) {
context.push(path.join(...key));
}
}
})({}, []);
const p = path.join(__dirname, 'node_modules');
const r1 = list(['**'], p);
const r2 = fs.walkDir(p);
console.log(isEqual(r1.sort(), r2.sort())); |
Should have everything available now to write a glob library 👍 |
Closing this. Eventually someone might build a glob library on this. Maybe me, maybe not =) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The ultimate goal is to get this library into a state where we can use it to power very efficient glob matching. The functionality is almost there. Missing:
*(pattern)
,@(pattern)
etc. Have to better understand how pattern are used with file extensions, e.g. what does'source/*(some|file).py'
mean?()
?See here for more information: https://facelessuser.github.io/wcmatch/glob/#syntax
Once equivalent functionality is fully supported it should be possible to write a glob library powered by
object-scan
.The text was updated successfully, but these errors were encountered: