Make a glob pattern absolute, ensuring that negative globs and patterns with trailing slashes are correctly handled.
npm install to-absolute-glob> Make a glob pattern absolute, ensuring that negative globs and patterns with trailing slashes are correctly handled.
Install with npm:
``sh`
npm install to-absolute-glob
Or install with yarn:
`sh`
yarn add to-absolute-glob
`js`
const toAbsGlob = require('to-absolute-glob');
toAbsGlob('a/*.js');
//=> '/dev/foo/a/*.js'
Given the current project folder (cwd) is /dev/foo/:
makes a path absolute
`js`
toAbsGlob('a');
//=> '/dev/foo/a'
makes a glob absolute
`js`
toAbsGlob('a/*.js');
//=> '/dev/foo/a/*.js'
retains trailing slashes
`js`
toAbsGlob('a/*/');
//=> '/dev/foo/a/*/'
retains trailing slashes with cwd
`js`
toAbsGlob('./fixtures/whatsgoingon/*/', {cwd: __dirname});
//=> '/dev/foo/'
makes a negative glob absolute
`js`
toAbsGlob('!a/*.js');
//=> '!/dev/foo/a/*.js'
from a cwd
`js`
toAbsGlob('a/*.js', {cwd: 'foo'});
//=> '/dev/foo/foo/a/*.js'
makes a negative glob absolute from a cwd
`js`
toAbsGlob('!a/*.js', {cwd: 'foo'});
//=> '!/dev/foo/foo/a/*.js'
from a root path
`js`
toAbsGlob('/a/*.js', {root: 'baz'});
//=> '/dev/foo/baz/a/*.js'
from a root slash
`js`
toAbsGlob('/a/*.js', {root: '/'});
//=> '/dev/foo/a/*.js'
from a negative root path
`js`
toAbsGlob('!/a/*.js', {root: 'baz'});
//=> '!/dev/foo/baz/a/*.js'
from a negative root slash
`js`
toAbsGlob('!/a/*.js', {root: '/'});
//=> '!/dev/foo/a/*.js'
* has-glob: Returns true if an array has a glob pattern. | truetrue if an array has a glob pattern."" class="text-primary hover:underline" target="_blank" rel="noopener noreferrer">homepage
* is-glob: Returns if the given string looks like a glob pattern or an extglob pattern… more | true if the given string looks like a glob pattern or an extglob pattern. This makes it easy to create code that only uses external modules like node-glob when necessary, resulting in much faster code execution and initialization time, and a bet"" class="text-primary hover:underline" target="_blank" rel="noopener noreferrer">homepage
* is-valid-glob: Return true if a value is a valid glob pattern or patterns. | homepage
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
| Commits | Contributor
|
| --- | --- |
| 16 | doowb |
| 15 | jonschlinkert |
| 1 | phated |
| 1 | erikkemperman |
_(This document was generated by verb-generate-readme (a verb generator), please don't edit the readme directly. Any changes to the readme must be made in .verb.md.)_
To generate the readme and API documentation with verb:
`sh`
$ npm install -g verb verb-generate-readme && verb
Install dev dependencies:
`sh``
$ npm install -d && npm test
Jon Schlinkert
* github/jonschlinkert
* twitter/jonschlinkert
Copyright (c) Jon Schlinkert.
Released under the MIT license.
*
_This file was generated by verb-generate-readme, v3.0.0, on November 17, 2022._