Socket
Socket
Sign inDemoInstall

glob

Package Overview
Dependencies
Maintainers
1
Versions
155
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

glob - npm Package Compare versions

Comparing version 4.1.6 to 4.2.0

10

common.js

@@ -63,2 +63,5 @@ exports.alphasort = alphasort

self.mark = !!options.mark
self.nodir = !!options.nodir
if (self.nodir)
self.mark = true
self.sync = !!options.sync

@@ -70,2 +73,4 @@ self.nounique = !!options.nounique

self.stat = !!options.stat
self.noprocess = !!options.noprocess
self.maxLength = options.maxLength || Infinity

@@ -134,2 +139,7 @@ self.cache = options.cache || Object.create(null)

}
if (self.nodir) {
all = all.filter(function (e) {
return !(/\/$/.test(e))
})
}
}

@@ -136,0 +146,0 @@

55

glob.js

@@ -58,2 +58,3 @@ // Approach:

var inflight = require("inflight")
var util = require("util")

@@ -78,2 +79,22 @@ var once = require("once")

// old api surface
glob.glob = glob
glob.hasMagic = function (pattern, options_) {
var options = util._extend({}, options_)
options.noprocess = true
var g = new Glob(pattern, options)
var set = g.minimatch.set
if (set.length > 1)
return true
for (var j = 0; j < set[0].length; j++) {
if (typeof set[0][j] !== 'string')
return true
}
return false
}
glob.Glob = Glob

@@ -124,2 +145,5 @@ inherits(Glob, EE)

if (this.noprocess)
return this
if (n === 0)

@@ -141,2 +165,5 @@ return done()

assert(this instanceof Glob)
if (this.aborted)
return
//console.error('FINISH', this.matches)

@@ -195,2 +222,5 @@ common.finish(this)

if (this.aborted)
return
this._processing++

@@ -204,5 +234,2 @@ if (this.paused) {

if (this.aborted)
return cb()
// Get the first [n] parts of pattern that are all strings.

@@ -347,2 +374,5 @@ var n = 0

Glob.prototype._emitMatch = function (index, e) {
if (this.aborted)
return
if (!this.matches[index][e]) {

@@ -353,2 +383,9 @@ if (this.paused) {

}
if (this.nodir) {
var c = this.cache[this._makeAbs(e)]
if (c === 'DIR' || Array.isArray(c))
return
}
this.matches[index][e] = true

@@ -367,2 +404,5 @@ if (!this.stat && !this.mark)

Glob.prototype._readdirInGlobStar = function (abs, cb) {
if (this.aborted)
return
var lstatkey = "lstat\0" + abs

@@ -393,2 +433,5 @@ var self = this

Glob.prototype._readdir = function (abs, inGlobStar, cb) {
if (this.aborted)
return
cb = inflight("readdir\0"+abs+"\0"+inGlobStar, cb)

@@ -425,2 +468,5 @@ if (!cb)

Glob.prototype._readdirEntries = function (abs, entries, cb) {
if (this.aborted)
return
// if we haven't asked to stat everything, then just

@@ -445,2 +491,5 @@ // assume that everything in there exists, so we can avoid

Glob.prototype._readdirError = function (f, er, cb) {
if (this.aborted)
return
// handle errors, and cache the information

@@ -447,0 +496,0 @@ switch (er.code) {

2

package.json

@@ -5,3 +5,3 @@ {

"description": "a little globber",
"version": "4.1.6",
"version": "4.2.0",
"repository": {

@@ -8,0 +8,0 @@ "type": "git",

@@ -103,2 +103,13 @@ [![Build Status](https://travis-ci.org/isaacs/node-glob.svg?branch=master)](https://travis-ci.org/isaacs/node-glob/) [![Dependency Status](https://david-dm.org/isaacs/node-glob.svg)](https://david-dm.org/isaacs/node-glob) [![devDependency Status](https://david-dm.org/isaacs/node-glob/dev-status.svg)](https://david-dm.org/isaacs/node-glob#info=devDependencies) [![optionalDependency Status](https://david-dm.org/isaacs/node-glob/optional-status.svg)](https://david-dm.org/isaacs/node-glob#info=optionalDependencies)

## glob.hasMagic(patter, [options])
Returns `true` if there are any special characters in the pattern, and
`false` otherwise.
Note that the options affect the results. If `noext:true` is set in
the options object, then `+(a|b)` will not be considered a magic
pattern. If the pattern has a brace expansion, like `a/{b/c,x/y}`
then that is considered magical, unless `nobrace:true` is set in the
options.
## glob(pattern, [options], cb)

@@ -162,2 +173,6 @@

array value is the results of `fs.readdir`
* `statCache` Cache of `fs.stat` results, to prevent statting the same
path multiple times.
* `symlinks` A record of which paths are symbolic links, which is
relevant in resolving `**` patterns.

@@ -189,4 +204,11 @@ ### Events

All options are added to the glob object, as well.
All options are added to the Glob object, as well.
If you are running many `glob` operations, you can pass a Glob object
as the `options` argument to a subsequent operation to shortcut some
`stat` and `readdir` calls. At the very least, you may pass in shared
`symlinks`, `statCache`, and `cache` options, so that parallel glob
operations will be sped up by sharing information about the
filesystem.
* `cwd` The current working directory in which to search. Defaults

@@ -208,32 +230,46 @@ to `process.cwd()`.

somewhat, and is completely unnecessary, unless `readdir` is presumed
to be an untrustworthy indicator of file existence. It will cause
ELOOP to be triggered one level sooner in the case of cyclical
symbolic links.
* `silent` When an unusual error is encountered
when attempting to read a directory, a warning will be printed to
stderr. Set the `silent` option to true to suppress these warnings.
* `strict` When an unusual error is encountered
when attempting to read a directory, the process will just continue on
in search of other matches. Set the `strict` option to raise an error
in these cases.
to be an untrustworthy indicator of file existence.
* `silent` When an unusual error is encountered when attempting to
read a directory, a warning will be printed to stderr. Set the
`silent` option to true to suppress these warnings.
* `strict` When an unusual error is encountered when attempting to
read a directory, the process will just continue on in search of
other matches. Set the `strict` option to raise an error in these
cases.
* `cache` See `cache` property above. Pass in a previously generated
cache object to save some fs calls.
* `statCache` A cache of results of filesystem information, to prevent
unnecessary stat calls. While it should not normally be necessary to
set this, you may pass the statCache from one glob() call to the
unnecessary stat calls. While it should not normally be necessary
to set this, you may pass the statCache from one glob() call to the
options object of another, if you know that the filesystem will not
change between calls. (See "Race Conditions" below.)
* `symlinks` A cache of known symbolic links. You may pass in a
previously generated `symlinks` object to save `lstat` calls when
resolving `**` matches.
* `sync` Perform a synchronous glob search.
* `nounique` In some cases, brace-expanded patterns can result in the
same file showing up multiple times in the result set. By default,
this implementation prevents duplicates in the result set.
Set this flag to disable that behavior.
this implementation prevents duplicates in the result set. Set this
flag to disable that behavior.
* `nonull` Set to never return an empty set, instead returning a set
containing the pattern itself. This is the default in glob(3).
* `nocase` Perform a case-insensitive match. Note that case-insensitive
filesystems will sometimes result in glob returning results that are
case-insensitively matched anyway, since readdir and stat will not
raise an error.
* `nocase` Perform a case-insensitive match. Note that
case-insensitive filesystems will sometimes result in glob returning
results that are case-insensitively matched anyway, since readdir
and stat will not raise an error.
* `debug` Set to enable debug logging in minimatch and glob.
* `globDebug` Set to enable debug logging in glob, but not minimatch.
* `nobrace` Do not expand `{a,b}` and `{1..3}` brace sets.
* `noglobstar` Do not match `**` against multiple filenames. (Ie,
treat it as a normal `*` instead.)
* `noext` Do not match `+(a|b)` "extglob" patterns.
* `nocase` Perform a case-insensitive match. Note: on
case-insensitive filesystems, non-magic patterns will match by
default, since `stat` and `readdir` will not raise errors.
* `matchBase` Perform a basename-only match if the pattern does not
contain any slash characters. That is, `*.js` would be treated as
equivalent to `**/*.js`, matching all js files in all directories.
* `nonegate` Suppress `negate` behavior. (See below.)
* `nocomment` Suppress `comment` behavior. (See below.)
* `nonull` Return the pattern when no matches are found.
* `nodir` Do not match directories, only files.

@@ -263,4 +299,5 @@ ## Comparisons to other fnmatch/glob implementations

Note that symlinked directories will not ever be crawled as part of a
`**` match. This prevents infinite loops and duplicates and the like.
Note that symlinked directories are not crawled as part of a `**`,
though their contents may match against subsequent portions of the
pattern. This prevents infinite loops and duplicates and the like.

@@ -267,0 +304,0 @@ If an escaped pattern has no matches, and the `nonull` flag is set,

@@ -37,2 +37,5 @@ module.exports = globSync

if (this.noprocess)
return this
var n = this.minimatch.set.length

@@ -184,2 +187,8 @@ this.matches = new Array(n)

if (!this.matches[index][e]) {
if (this.nodir) {
var c = this.cache[this._makeAbs(e)]
if (c === 'DIR' || Array.isArray(c))
return
}
this.matches[index][e] = true

@@ -186,0 +195,0 @@ if (this.stat || this.mark)

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc