Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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 1.1.0 to 2.0.7

deps/fnmatch/fnmatch.c

31

lib/glob.js
// the nice wrapper around the raw C++ binding.
var binding = require("../build/default/glob")
var binding = require(process.env.GLOB_DEBUG != undefined
? "../build/default/glob_g"
: "../build/default/glob")

@@ -11,18 +13,33 @@ exports.glob = glob

.filter(function (k) { return k.match(/^GLOB_/) })
.forEach(function (k) { exports[k] = binding[k], exports[binding[k]] = k })
.forEach(function (k) {
glob[k] = globSync[k] = exports[k] = binding[k]
globSync[binding[k]] = glob[binding[k]] = k
})
Object.keys(binding)
.filter(function (k) { return k.match(/^FNM_/) })
.forEach(function (k) { exports[k] = binding[k] })
.forEach(function (k) {
fnmatch[k] = exports[k] = binding[k]
fnmatch[binding[k]] = k
})
// most shells set these, so use them as the defaults.
// sane defaults.
exports.FNM_DEFAULT = binding.FNM_PATHNAME | binding.FNM_PERIOD
fnmatch.FNM_DEFAULT = exports.FNM_DEFAULT
fnmatch[fnmatch.FNM_DEFAULT] = "FNM_DEFAULT"
exports.GLOB_DEFAULT = binding.GLOB_BRACE
| binding.GLOB_STAR
| binding.GLOB_MARK
| binding.GLOB_TILDE
glob.GLOB_DEFAULT = globSync.GLOB_DEFAULT = exports.GLOB_DEFAULT
glob[glob.GLOB_DEFAULT] = globSync[glob.GLOB_DEFAULT] = "GLOB_DEFAULT"
function glob (pattern, flags, cb) {
// console.log("glob", pattern, flags, cb)
if (typeof cb !== "function") cb = flags, flags = 0
if (typeof cb !== "function") cb = flags, flags = null
if (typeof cb !== "function") throw new Error(
"usage: glob(pattern, [flags,] cb)")
if (!flags) flags = 0
if (!flags) flags = exports.GLOB_DEFAULT

@@ -42,3 +59,3 @@ // console.log("glob", pattern, flags, cb)

function globSync (pattern, flags) {
if (!flags) flags = 0
if (!flags) flags = exports.GLOB_DEFAULT
if (typeof pattern !== "string") throw new Error(

@@ -45,0 +62,0 @@ "usage: globSync(pattern [, flags])")

{ "name" : "glob"
, "description" : "glob/fnmatch binding for node"
, "author" : "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)"
, "version" : "1.1.0"
, "version" : "2.0.7"
, "main" : "./lib/glob"
, "repository" : "git://github.com/isaacs/node-glob.git"
, "homepage" : "https://github.com/isaacs/node-glob"
, "keywords" : ["glob", "pattern", "match", "filesystem", "posix", "fnmatch"]
, "bugs" : { "web" : "https://github.com/isaacs/node-glob/issues" }
, "engines": { "node": "0.4" }
}
var g = require("../lib/glob")
process.chdir(__dirname)
var failures = 0
function testSync(pattern, flags) {
console.error("testing: %j %j", pattern, flags)
console.error(g.globSync(pattern, flags))
}
try {
console.log(g.globSync("*", 0))
console.log(g.globSync("*/*.js", 0))
console.log(g.globSync("lib/*", 0))
console.log(g.globSync("~/*", g.GLOB_TILDE))
testSync("*", 0)
testSync("*/*.js", 0)
testSync("lib/*", 0)
testSync("~/*", g.GLOB_TILDE)
testSync("foo/**/bar")
} catch (ex) {
console.log(ex.stack)
console.error(ex.stack)
failures ++
}
g.glob("*", 0, function (er, m) {
console.log(er, m)
g.glob("*/*.js", 0, function (er, m) {
console.log(er, m)
g.glob("lib/*", 0, function (er, m) {
console.log(er, m)
g.glob("~/*", 0 | g.GLOB_TILDE, function(er, m) {
console.log(er, m)
console.log("ok")
})
})
function testAsync (pattern, flags, cb) {
if (!cb) cb = flags, flags = undefined
console.error("testing async: %j %j", pattern, flags)
g.glob(pattern, flags, function (er, m) {
if (er) {
console.error(" FAIL: "+(er.stack||er.message))
failures ++
} else console.error(" %j", m)
cb()
})
})
}
function testAsyncList (list, cb) {
next()
function next (er, m) {
var test = list.shift()
if (!test) return cb()
test.push(cb)
testAsync.apply(null, test)
}
}
testAsyncList
([["*", 0]
,["../*/*.js", 0]
,["../lib/*", 0]
,["~/*", g.GLOB_DEFAULT | g.GLOB_TILDE]
,["foo/**/bar"]
]
,testFnmatch)
function f (pattern, str, flags, expect) {
if (arguments.length === 3) expect = flags, flags = undefined
if (g.fnmatch(pattern, str, flags) !== expect) {
throw new Error(JSON.stringify([pattern,str,flags]) + " expected "+expect)
var actual = g.fnmatch(pattern, str, flags)
if (actual !== expect) {
console.error("Fail: "+JSON.stringify([pattern,str,flags]) + " expected "+expect + " actual "+actual)
failures ++
}

@@ -34,9 +63,22 @@ console.error("%s, %s, %s => %j", pattern, str, flags, expect)

f("*", "foo", true)
f(".*", "foo", false)
f("*", ".foo", false)
f("*", "foo/bar", false)
f("*/*", "foo/bar", true)
f("*", ".foo", g.FNM_DEFAULT & ~g.FNM_PERIOD, true)
f("*/*", "foo/bar", g.FNM_DEFAULT & ~g.FNM_PATHNAME, true)
function testFnmatch () {
f("*", "foo", true)
f(".*", "foo", false)
f("*", ".foo", false)
f("*", "foo/bar", false)
f("*/*", "foo/bar", true)
f("*", ".foo", g.FNM_DEFAULT & ~g.FNM_PERIOD, true)
f("*/*", "foo/bar", g.FNM_DEFAULT & ~g.FNM_PATHNAME, true)
f("**/bar", "foo/bar", true)
f("**/bar", "foo/baz/bar", true)
f("foo/**/bar", "foo/bar/baz/quux/bar", true)
done()
}
function done () {
if (failures === 0) console.log("ok")
else {
console.error("Failures: %j", failures)
process.exit(failures)
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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