Magic Paths
Expand prefixed glob patterns into an array of matching files. The real advantage of this over using a glob matching library by itself is to be able to use path shortcuts that can reference one or more base location.
Instead of this: some/deeply/nested/folder/*.*
you can set a prefix and reference the files in the folder like this nested:*.*
. Very useful when the prefix references multiple locations.
Usage
var magic = require('magic-paths');
var options = {
prefixes: {
rel_fixture: 'test/fixtures/'
}
};
magic.expand('rel_fixture:*.html', options, function(err, files) {
});
magic.expand('rel_fixture:*.html', options).then(function(files) {
}).catch(function(err){})
Note: - the trailing slash for directory prefixes is important. Prefixes may not necessarily be full directory paths so it's not possible to automagically resolve them as such.