Comparing version 1.1.0 to 2.0.7
// 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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Non-existent author
Supply chain riskThe package was published by an npm account that no longer exists.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No License Found
License(Experimental) License information could not be found.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
67608
19
0
143
0
149
0
3
1