Skip to content
Browse files

include dep test/examples

  • Loading branch information...
1 parent efbf027 commit d4b2d1149a0f2b56467ebeebd36e21d3a2bfe48a @isaacs isaacs committed Jun 6, 2012
View
46 node_modules/node-gyp/node_modules/ansi/examples/imgcat.js
@@ -0,0 +1,46 @@
+#!/usr/bin/env node
+
+var ansi = require('../')
+ , cursor = ansi(process.stdout)
+ , tty = require('tty')
+ , Canvas = require('canvas')
+ , imageFile = process.argv[2] || __dirname + '/yoshi.png'
+ , image = require('fs').readFileSync(imageFile)
+ , pixel = ' '
+ , alphaThreshold = 0
+
+var img = new Canvas.Image();
+img.src = image;
+
+function draw () {
+ var width = process.stdout.getWindowSize()[0] / pixel.length | 0
+ , scaleW = img.width > width ? width / img.width : 1
+ , w = Math.floor(img.width * scaleW)
+ , h = Math.floor(img.height * scaleW);
+
+ var canvas = new Canvas(w, h)
+ , ctx = canvas.getContext('2d');
+
+ ctx.drawImage(img, 0, 0, w, h);
+
+ var data = ctx.getImageData(0, 0, w, h).data;
+
+ for (var i=0, l=data.length; i<l; i+=4) {
+ var r = data[i]
+ , g = data[i+1]
+ , b = data[i+2]
+ , alpha = data[i+3];
+ if (alpha > alphaThreshold) {
+ cursor.bg.rgb(r, g, b);
+ } else {
+ cursor.bg.reset();
+ }
+ process.stdout.write(pixel);
+ if ((i/4|0) % w === (w-1)) {
+ cursor.bg.reset();
+ process.stdout.write('\n');
+ }
+ }
+}
+
+draw();
View
BIN node_modules/node-gyp/node_modules/ansi/examples/yoshi.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
2 node_modules/node-gyp/node_modules/ansi/package.json
@@ -41,7 +41,7 @@
"dependencies": {},
"optionalDependencies": {},
"_engineSupported": true,
- "_npmVersion": "1.1.23",
+ "_npmVersion": "1.1.24",
"_nodeVersion": "v0.7.10-pre",
"_defaultsLoaded": true,
"_from": "ansi@0.0.x"
View
9 node_modules/node-gyp/node_modules/glob/examples/g.js
@@ -0,0 +1,9 @@
+var Glob = require("../").Glob
+
+var pattern = "test/a/**/[cg]/../[cg]"
+console.log(pattern)
+
+var mg = new Glob(pattern, {mark: true, sync:true}, function (er, matches) {
+ console.log("matches", matches)
+})
+console.log("after")
View
9 node_modules/node-gyp/node_modules/glob/examples/usr-local.js
@@ -0,0 +1,9 @@
+var Glob = require("../").Glob
+
+var pattern = "{./*/*,/*,/usr/local/*}"
+console.log(pattern)
+
+var mg = new Glob(pattern, {mark: true}, function (er, matches) {
+ console.log("matches", matches)
+})
+console.log("after")
View
2 node_modules/node-gyp/node_modules/glob/package.json
@@ -36,7 +36,7 @@
"_id": "glob@3.1.9",
"optionalDependencies": {},
"_engineSupported": true,
- "_npmVersion": "1.1.23",
+ "_npmVersion": "1.1.24",
"_nodeVersion": "v0.7.10-pre",
"_defaultsLoaded": true,
"_from": "glob@3"
View
61 node_modules/node-gyp/node_modules/glob/test/00-setup.js
@@ -0,0 +1,61 @@
+// just a little pre-run script to set up the fixtures.
+// zz-finish cleans it up
+
+var mkdirp = require("mkdirp")
+var path = require("path")
+var i = 0
+var tap = require("tap")
+var fs = require("fs")
+var rimraf = require("rimraf")
+
+var files =
+[ "a/.abcdef/x/y/z/a"
+, "a/abcdef/g/h"
+, "a/abcfed/g/h"
+, "a/b/c/d"
+, "a/bc/e/f"
+, "a/c/d/c/b"
+, "a/cb/e/f"
+]
+
+var symlinkTo = path.resolve(__dirname, "a/symlink/a/b/c")
+var symlinkFrom = "../.."
+
+files = files.map(function (f) {
+ return path.resolve(__dirname, f)
+})
+
+tap.test("remove fixtures", function (t) {
+ rimraf(path.resolve(__dirname, "a"), function (er) {
+ t.ifError(er, "remove fixtures")
+ t.end()
+ })
+})
+
+files.forEach(function (f) {
+ tap.test(f, function (t) {
+ var d = path.dirname(f)
+ mkdirp(d, 0755, function (er) {
+ if (er) {
+ t.fail(er)
+ return t.bailout()
+ }
+ fs.writeFile(f, "i like tests", function (er) {
+ t.ifError(er, "make file")
+ t.end()
+ })
+ })
+ })
+})
+
+tap.test("symlinky", function (t) {
+ var d = path.dirname(symlinkTo)
+ console.error("mkdirp", d)
+ mkdirp(d, 0755, function (er) {
+ t.ifError(er)
+ fs.symlink(symlinkFrom, symlinkTo, function (er) {
+ t.ifError(er, "make symlink")
+ t.end()
+ })
+ })
+})
View
119 node_modules/node-gyp/node_modules/glob/test/bash-comparison.js
@@ -0,0 +1,119 @@
+// basic test
+// show that it does the same thing by default as the shell.
+var tap = require("tap")
+, child_process = require("child_process")
+
+// put more patterns here.
+, globs =
+ [
+ "test/a/*/+(c|g)/./d"
+ ,"test/a/**/[cg]/../[cg]"
+ ,"test/a/{b,c,d,e,f}/**/g"
+ ,"test/a/b/**"
+ ,"test/**/g"
+ ,"test/a/abc{fed,def}/g/h"
+ ,"test/a/abc{fed/g,def}/**/"
+ ,"test/a/abc{fed/g,def}/**///**/"
+ ,"test/**/a/**/"
+ ,"test/+(a|b|c)/a{/,bc*}/**"
+ ,"test/*/*/*/f"
+ ,"test/**/f"
+ ,"test/a/symlink/a/b/c/a/b/c/a/b/c//a/b/c////a/b/c/**/b/c/**"
+ ,"{./*/*,/usr/local/*}"
+ ,"{/*,*}" // evil owl face! how you taunt me!
+ ]
+, glob = require("../")
+, path = require("path")
+
+// run from the root of the project
+// this is usually where you're at anyway, but be sure.
+process.chdir(path.resolve(__dirname, ".."))
+
+function alphasort (a, b) {
+ a = a.toLowerCase()
+ b = b.toLowerCase()
+ return a > b ? 1 : a < b ? -1 : 0
+}
+
+globs.forEach(function (pattern) {
+ var echoOutput
+ tap.test(pattern, function (t) {
+ var bashPattern = pattern
+ , cmd = "shopt -s globstar && " +
+ "shopt -s extglob && " +
+ "shopt -s nullglob && " +
+ // "shopt >&2; " +
+ "eval \'for i in " + bashPattern + "; do echo $i; done\'"
+ , cp = child_process.spawn("bash", ["-c",cmd])
+ , out = []
+ , globResult
+ cp.stdout.on("data", function (c) {
+ out.push(c)
+ })
+ cp.stderr.on("data", function (c) {
+ process.stderr.write(c)
+ })
+ cp.stdout.on("close", function () {
+ echoOutput = flatten(out)
+ if (!echoOutput) echoOutput = []
+ else {
+ echoOutput = echoOutput.split(/\r*\n/).map(function (m) {
+ // Bash is a oddly inconsistent with slashes in the
+ // the results. This implementation is a bit more
+ // normalized. Account for this in the test results.
+ return m.replace(/\/+/g, "/").replace(/\/$/, "")
+ }).sort(alphasort).reduce(function (set, f) {
+ if (f !== set[set.length - 1]) set.push(f)
+ return set
+ }, []).sort(alphasort)
+ }
+ next()
+ })
+
+ glob(pattern, function (er, matches) {
+ // sort and unpark, just to match the shell results
+ matches = matches.map(function (m) {
+ return m.replace(/\/+/g, "/").replace(/\/$/, "")
+ }).sort(alphasort).reduce(function (set, f) {
+ if (f !== set[set.length - 1]) set.push(f)
+ return set
+ }, []).sort(alphasort)
+
+ t.ifError(er, pattern + " should not error")
+ globResult = matches
+ next()
+ })
+
+ function next () {
+ if (!echoOutput || !globResult) return
+
+ t.deepEqual(globResult, echoOutput, "should match shell")
+ t.end()
+ }
+ })
+
+ tap.test(pattern + " sync", function (t) {
+ var matches = glob.sync(pattern).map(function (m) {
+ return m.replace(/\/+/g, "/").replace(/\/$/, "")
+ }).sort(alphasort).reduce(function (set, f) {
+ if (f !== set[set.length - 1]) set.push(f)
+ return set
+ }, []).sort(alphasort)
+
+ t.deepEqual(matches, echoOutput, "should match shell")
+ t.end()
+ })
+})
+
+function flatten (chunks) {
+ var s = 0
+ chunks.forEach(function (c) { s += c.length })
+ var out = new Buffer(s)
+ s = 0
+ chunks.forEach(function (c) {
+ c.copy(out, s)
+ s += c.length
+ })
+
+ return out.toString().trim()
+}
View
55 node_modules/node-gyp/node_modules/glob/test/cwd-test.js
@@ -0,0 +1,55 @@
+var tap = require("tap")
+
+var origCwd = process.cwd()
+process.chdir(__dirname)
+
+tap.test("changing cwd and searching for **/d", function (t) {
+ var glob = require('../')
+ var path = require('path')
+ t.test('.', function (t) {
+ glob('**/d', function (er, matches) {
+ t.ifError(er)
+ t.like(matches, [ 'a/b/c/d', 'a/c/d' ])
+ t.end()
+ })
+ })
+
+ t.test('a', function (t) {
+ glob('**/d', {cwd:path.resolve('a')}, function (er, matches) {
+ t.ifError(er)
+ t.like(matches, [ 'b/c/d', 'c/d' ])
+ t.end()
+ })
+ })
+
+ t.test('a/b', function (t) {
+ glob('**/d', {cwd:path.resolve('a/b')}, function (er, matches) {
+ t.ifError(er)
+ t.like(matches, [ 'c/d' ])
+ t.end()
+ })
+ })
+
+ t.test('a/b/', function (t) {
+ glob('**/d', {cwd:path.resolve('a/b/')}, function (er, matches) {
+ t.ifError(er)
+ t.like(matches, [ 'c/d' ])
+ t.end()
+ })
+ })
+
+ t.test('.', function (t) {
+ glob('**/d', {cwd: process.cwd()}, function (er, matches) {
+ t.ifError(er)
+ t.like(matches, [ 'a/b/c/d', 'a/c/d' ])
+ t.end()
+ })
+ })
+
+ t.test('cd -', function (t) {
+ process.chdir(origCwd)
+ t.end()
+ })
+
+ t.end()
+})
View
98 node_modules/node-gyp/node_modules/glob/test/pause-resume.js
@@ -0,0 +1,98 @@
+// show that no match events happen while paused.
+var tap = require("tap")
+, child_process = require("child_process")
+// just some gnarly pattern with lots of matches
+, pattern = "test/a/symlink/a/b/c/a/b/c/a/b/c//a/b/c////a/b/c/**/b/c/**"
+, glob = require("../")
+, Glob = glob.Glob
+, path = require("path")
+
+// run from the root of the project
+// this is usually where you're at anyway, but be sure.
+process.chdir(path.resolve(__dirname, ".."))
+
+function alphasort (a, b) {
+ a = a.toLowerCase()
+ b = b.toLowerCase()
+ return a > b ? 1 : a < b ? -1 : 0
+}
+
+function cleanResults (m) {
+ // normalize discrepancies in ordering, duplication,
+ // and ending slashes.
+ return m.map(function (m) {
+ return m.replace(/\/+/g, "/").replace(/\/$/, "")
+ }).sort(alphasort).reduce(function (set, f) {
+ if (f !== set[set.length - 1]) set.push(f)
+ return set
+ }, []).sort(alphasort)
+}
+
+function flatten (chunks) {
+ var s = 0
+ chunks.forEach(function (c) { s += c.length })
+ var out = new Buffer(s)
+ s = 0
+ chunks.forEach(function (c) {
+ c.copy(out, s)
+ s += c.length
+ })
+
+ return out.toString().trim()
+}
+var bashResults
+tap.test("get bash output", function (t) {
+ var bashPattern = pattern
+ , cmd = "shopt -s globstar && " +
+ "shopt -s extglob && " +
+ "shopt -s nullglob && " +
+ // "shopt >&2; " +
+ "eval \'for i in " + bashPattern + "; do echo $i; done\'"
+ , cp = child_process.spawn("bash", ["-c",cmd])
+ , out = []
+ , globResult
+ cp.stdout.on("data", function (c) {
+ out.push(c)
+ })
+ cp.stderr.on("data", function (c) {
+ process.stderr.write(c)
+ })
+ cp.stdout.on("close", function () {
+ bashResults = flatten(out)
+ if (!bashResults) return t.fail("Didn't get results from bash")
+ else {
+ bashResults = cleanResults(bashResults.split(/\r*\n/))
+ }
+ t.ok(bashResults.length, "got some results")
+ t.end()
+ })
+})
+
+var globResults = []
+tap.test("use a Glob object, and pause/resume it", function (t) {
+ var g = new Glob(pattern)
+ , paused = false
+ , res = []
+
+ g.on("match", function (m) {
+ t.notOk(g.paused, "must not be paused")
+ globResults.push(m)
+ g.pause()
+ t.ok(g.paused, "must be paused")
+ setTimeout(g.resume.bind(g), 1)
+ })
+
+ g.on("end", function (matches) {
+ t.pass("reached glob end")
+ globResults = cleanResults(globResults)
+ matches = cleanResults(matches)
+ t.deepEqual(matches, globResults,
+ "end event matches should be the same as match events")
+
+ t.deepEqual(matches, bashResults,
+ "glob matches should be the same as bash results")
+
+ t.end()
+ })
+})
+
View
39 node_modules/node-gyp/node_modules/glob/test/root-nomount.js
@@ -0,0 +1,39 @@
+var tap = require("tap")
+
+var origCwd = process.cwd()
+process.chdir(__dirname)
+
+tap.test("changing root and searching for /b*/**", function (t) {
+ var glob = require('../')
+ var path = require('path')
+ t.test('.', function (t) {
+ glob('/b*/**', { globDebug: true, root: '.', nomount: true }, function (er, matches) {
+ t.ifError(er)
+ t.like(matches, [])
+ t.end()
+ })
+ })
+
+ t.test('a', function (t) {
+ glob('/b*/**', { globDebug: true, root: path.resolve('a'), nomount: true }, function (er, matches) {
+ t.ifError(er)
+ t.like(matches, [ '/b', '/b/c', '/b/c/d', '/bc', '/bc/e', '/bc/e/f' ])
+ t.end()
+ })
+ })
+
+ t.test('root=a, cwd=a/b', function (t) {
+ glob('/b*/**', { globDebug: true, root: 'a', cwd: path.resolve('a/b'), nomount: true }, function (er, matches) {
+ t.ifError(er)
+ t.like(matches, [ '/b', '/b/c', '/b/c/d', '/bc', '/bc/e', '/bc/e/f' ])
+ t.end()
+ })
+ })
+
+ t.test('cd -', function (t) {
+ process.chdir(origCwd)
+ t.end()
+ })
+
+ t.end()
+})
View
43 node_modules/node-gyp/node_modules/glob/test/root.js
@@ -0,0 +1,43 @@
+var tap = require("tap")
+
+var origCwd = process.cwd()
+process.chdir(__dirname)
+
+tap.test("changing root and searching for /b*/**", function (t) {
+ var glob = require('../')
+ var path = require('path')
+ t.test('.', function (t) {
+ glob('/b*/**', { globDebug: true, root: '.' }, function (er, matches) {
+ t.ifError(er)
+ t.like(matches, [])
+ t.end()
+ })
+ })
+
+ t.test('a', function (t) {
+ glob('/b*/**', { globDebug: true, root: path.resolve('a') }, function (er, matches) {
+ t.ifError(er)
+ t.like(matches, [ '/b', '/b/c', '/b/c/d', '/bc', '/bc/e', '/bc/e/f' ].map(function (m) {
+ return path.join(path.resolve('a'), m)
+ }))
+ t.end()
+ })
+ })
+
+ t.test('root=a, cwd=a/b', function (t) {
+ glob('/b*/**', { globDebug: true, root: 'a', cwd: path.resolve('a/b') }, function (er, matches) {
+ t.ifError(er)
+ t.like(matches, [ '/b', '/b/c', '/b/c/d', '/bc', '/bc/e', '/bc/e/f' ].map(function (m) {
+ return path.join(path.resolve('a'), m)
+ }))
+ t.end()
+ })
+ })
+
+ t.test('cd -', function (t) {
+ process.chdir(origCwd)
+ t.end()
+ })
+
+ t.end()
+})
View
11 node_modules/node-gyp/node_modules/glob/test/zz-cleanup.js
@@ -0,0 +1,11 @@
+// remove the fixtures
+var tap = require("tap")
+, rimraf = require("rimraf")
+, path = require("path")
+
+tap.test("cleanup fixtures", function (t) {
+ rimraf(path.resolve(__dirname, "a"), function (er) {
+ t.ifError(er, "removed")
+ t.end()
+ })
+})
View
7 node_modules/node-gyp/package.json
@@ -51,11 +51,8 @@
"devDependencies": {},
"optionalDependencies": {},
"_engineSupported": true,
- "_npmVersion": "1.1.23",
+ "_npmVersion": "1.1.24",
"_nodeVersion": "v0.7.10-pre",
"_defaultsLoaded": true,
- "dist": {
- "shasum": "9ddb9c4218322fd3d6b9771b27c236c4e5965e3b"
- },
- "_from": "node-gyp@~0.4.4"
+ "_from": "node-gyp@~0.4.5"
}
View
3 node_modules/npmlog/package.json
@@ -35,5 +35,8 @@
"_npmVersion": "1.1.24",
"_nodeVersion": "v0.7.10-pre",
"_defaultsLoaded": true,
+ "dist": {
+ "shasum": "f0cf4b2c519950c00e91ba8e2868b62bf86254f6"
+ },
"_from": "npmlog@0"
}
View
2 package.json
@@ -98,7 +98,7 @@
},
"scripts": {
"test": "node ./test/run.js",
- "prepublish": "npm prune; rm -rf node_modules/*/{test,example,bench}*; make -j4 doc",
+ "prepublish": "npm prune; make -j4 doc",
"dumpconf": "env | grep npm | sort | uniq"
},
"licenses": [

0 comments on commit d4b2d11

Please sign in to comment.
Something went wrong with that request. Please try again.