Skip to content

ironikart/magic-paths

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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/'
    }
};

// Fetch files (callback style)
magic.expand('rel_fixture:*.html', options, function(err, files) {
    // ...
});

// Fetch files (promise style)
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.

About

Magic path resolutions using preset prefixes and globbing

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published