diff options
author | isaacs <i@izs.me> | 2012-07-13 20:21:25 +0400 |
---|---|---|
committer | isaacs <i@izs.me> | 2012-07-13 20:21:25 +0400 |
commit | 6589a195c4e5f5e8e1414d21ab286bca52a30b6c (patch) | |
tree | f8e7a29699b4235f41ec31ec5d4b7398a51b8547 /node_modules/fstream-npm | |
parent | 8fc010b701c58b508a0d5b76ee5b279ba1510fbe (diff) |
fstream-npm@0.1.1
Diffstat (limited to 'node_modules/fstream-npm')
19 files changed, 415 insertions, 27 deletions
diff --git a/node_modules/fstream-npm/example/bundle.js b/node_modules/fstream-npm/example/bundle.js new file mode 100644 index 000000000..159e4f7b6 --- /dev/null +++ b/node_modules/fstream-npm/example/bundle.js @@ -0,0 +1,13 @@ +// this example will bundle every dependency +var P = require("../") +P({ path: "./" }) + .on("package", bundleIt) + .on("entry", function (e) { + console.error(e.constructor.name, e.path.substr(e.root.dirname.length + 1)) + e.on("package", bundleIt) + }) + +function bundleIt (p) { + p.bundleDependencies = Object.keys(p.dependencies || {}) +} + diff --git a/node_modules/fstream-npm/example/dir-tar.js b/node_modules/fstream-npm/example/dir-tar.js new file mode 100644 index 000000000..f2bad92e0 --- /dev/null +++ b/node_modules/fstream-npm/example/dir-tar.js @@ -0,0 +1,19 @@ +// this will show what ends up in the fstream-npm package +var P = require("fstream").DirReader +var tar = require("tar") +function f (entry) { + return entry.basename !== ".git" +} + +new P({ path: "./", type: "Directory", Directory: true, filter: f }) + .on("package", function (p) { + console.error("package", p) + }) + .on("ignoreFile", function (e) { + console.error("ignoreFile", e) + }) + .on("entry", function (e) { + console.error(e.constructor.name, e.path.substr(e.root.path.length + 1)) + }) + .pipe(tar.Pack()) + .pipe(process.stdout) diff --git a/node_modules/fstream-npm/example/dir.js b/node_modules/fstream-npm/example/dir.js new file mode 100644 index 000000000..75e2eed0f --- /dev/null +++ b/node_modules/fstream-npm/example/dir.js @@ -0,0 +1,25 @@ +// this will show what ends up in the fstream-npm package +var P = require("../") +var DW = require("fstream").DirWriter + +var target = new DW({ Directory: true, type: "Directory", + path: __dirname + "/output"}) + +function f (entry) { + return entry.basename !== ".git" +} + +P({ path: "./", type: "Directory", isDirectory: true, filter: f }) + .on("package", function (p) { + console.error("package", p) + }) + .on("ignoreFile", function (e) { + console.error("ignoreFile", e) + }) + .on("entry", function (e) { + console.error(e.constructor.name, e.path) + }) + .pipe(target) + .on("end", function () { + console.error("ended") + }) diff --git a/node_modules/fstream-npm/example/example.js b/node_modules/fstream-npm/example/example.js new file mode 100644 index 000000000..0b53931ca --- /dev/null +++ b/node_modules/fstream-npm/example/example.js @@ -0,0 +1,12 @@ +// this will show what ends up in the fstream-npm package +var P = require("../") +P({ path: "./" }) + .on("package", function (p) { + console.error("package", p) + }) + .on("ignoreFile", function (e) { + console.error("ignoreFile", e) + }) + .on("entry", function (e) { + console.error(e.constructor.name, e.path.substr(e.root.dirname.length + 1)) + }) diff --git a/node_modules/fstream-npm/example/ig-tar.js b/node_modules/fstream-npm/example/ig-tar.js new file mode 100644 index 000000000..c1db81050 --- /dev/null +++ b/node_modules/fstream-npm/example/ig-tar.js @@ -0,0 +1,19 @@ +// this will show what ends up in the fstream-npm package +var P = require("fstream-ignore") +var tar = require("tar") +function f (entry) { + return entry.basename !== ".git" +} + +new P({ path: "./", type: "Directory", Directory: true, filter: f }) + .on("package", function (p) { + console.error("package", p) + }) + .on("ignoreFile", function (e) { + console.error("ignoreFile", e) + }) + .on("entry", function (e) { + console.error(e.constructor.name, e.path.substr(e.root.path.length + 1)) + }) + .pipe(tar.Pack()) + .pipe(process.stdout) diff --git a/node_modules/fstream-npm/example/tar.js b/node_modules/fstream-npm/example/tar.js new file mode 100644 index 000000000..f9bcaea81 --- /dev/null +++ b/node_modules/fstream-npm/example/tar.js @@ -0,0 +1,25 @@ +// this will show what ends up in the fstream-npm package +var P = require("../") +var tar = require("tar") +function f () { + return true +} +// function f (entry) { +// return entry.basename !== ".git" +// } + +new P({ path: "./", type: "Directory", isDirectory: true, filter: f }) + .on("package", function (p) { + console.error("package", p) + }) + .on("ignoreFile", function (e) { + console.error("ignoreFile", e) + }) + .on("entry", function (e) { + console.error(e.constructor.name, e.path) + }) + .on("end", function () { + console.error("ended") + }) + .pipe(tar.Pack()) + .pipe(process.stdout) diff --git a/node_modules/fstream-npm/fstream-npm.js b/node_modules/fstream-npm/fstream-npm.js index 43c0f169f..5678347b0 100644 --- a/node_modules/fstream-npm/fstream-npm.js +++ b/node_modules/fstream-npm/fstream-npm.js @@ -90,6 +90,9 @@ Packer.prototype.applyIgnores = function (entry, partial, entryObj) { // package.json files can never be ignored. if (entry === "package.json") return true + // readme files should never be ignored. + if (entry.match(/^readme(\.[^\.]*)$/i)) return true + // special rules. see below. if (entry === "node_modules" && this.packageRoot) return true diff --git a/node_modules/fstream-npm/node_modules/fstream-ignore/example/basic.js b/node_modules/fstream-npm/node_modules/fstream-ignore/example/basic.js new file mode 100644 index 000000000..ff4534289 --- /dev/null +++ b/node_modules/fstream-npm/node_modules/fstream-ignore/example/basic.js @@ -0,0 +1,13 @@ +var Ignore = require("../") +Ignore({ path: __dirname + , ignoreFiles: [".ignore", ".gitignore"] + }) + .on("child", function (c) { + console.error(c.path.substr(c.root.path.length + 1)) + c.on("ignoreFile", onIgnoreFile) + }) + .on("ignoreFile", onIgnoreFile) + +function onIgnoreFile (e) { + console.error("adding ignore file", e.path) +} diff --git a/node_modules/fstream-npm/node_modules/fstream-ignore/package.json b/node_modules/fstream-npm/node_modules/fstream-ignore/package.json index ed82c6543..773e797d6 100644 --- a/node_modules/fstream-npm/node_modules/fstream-ignore/package.json +++ b/node_modules/fstream-npm/node_modules/fstream-ignore/package.json @@ -25,18 +25,7 @@ "rimraf": "", "mkdirp": "" }, - "_npmUser": { - "name": "isaacs", - "email": "i@izs.me" - }, + "readme": "# fstream-ignore\n\nA fstream DirReader that filters out files that match globs in `.ignore`\nfiles throughout the tree, like how git ignores files based on a\n`.gitignore` file.\n\nHere's an example:\n\n```javascript\nvar Ignore = require(\"fstream-ignore\")\nIgnore({ path: __dirname\n , ignoreFiles: [\".ignore\", \".gitignore\"]\n })\n .on(\"child\", function (c) {\n console.error(c.path.substr(c.root.path.length + 1))\n })\n .pipe(tar.Pack())\n .pipe(fs.createWriteStream(\"foo.tar\"))\n```\n\nThis will tar up the files in __dirname into `foo.tar`, ignoring\nanything matched by the globs in any .iginore or .gitignore file.\n", "_id": "fstream-ignore@0.0.5", - "optionalDependencies": {}, - "engines": { - "node": "*" - }, - "_engineSupported": true, - "_npmVersion": "1.1.23", - "_nodeVersion": "v0.7.10-pre", - "_defaultsLoaded": true, "_from": "fstream-ignore@~0.0.5" } diff --git a/node_modules/fstream-npm/node_modules/fstream-ignore/test/.ignore b/node_modules/fstream-npm/node_modules/fstream-ignore/test/.ignore new file mode 100644 index 000000000..773679d45 --- /dev/null +++ b/node_modules/fstream-npm/node_modules/fstream-ignore/test/.ignore @@ -0,0 +1,2 @@ +.gitignore +.*.swp diff --git a/node_modules/fstream-npm/node_modules/fstream-ignore/test/.npmignore b/node_modules/fstream-npm/node_modules/fstream-ignore/test/.npmignore new file mode 100644 index 000000000..1b26d0de5 --- /dev/null +++ b/node_modules/fstream-npm/node_modules/fstream-ignore/test/.npmignore @@ -0,0 +1 @@ +*/a diff --git a/node_modules/fstream-npm/node_modules/fstream-ignore/test/00-setup.js b/node_modules/fstream-npm/node_modules/fstream-ignore/test/00-setup.js new file mode 100644 index 000000000..7d7e4a1b7 --- /dev/null +++ b/node_modules/fstream-npm/node_modules/fstream-ignore/test/00-setup.js @@ -0,0 +1,71 @@ +// The test fixtures work like this: +// These dirs are all created: {a,b,c}/{a,b,c}/{a,b,c}/ +// in each one, these files are created: +// {.,}{a,b,c}{a,b,c}{a,b,c} +// +// So, there'll be a/b/c/abc, a/b/c/aba, etc., and dot-versions of each. +// +// Each test then writes their own ignore file rules for their purposes, +// and is responsible for removing them afterwards. + +var mkdirp = require("mkdirp") +var path = require("path") +var i = 0 +var tap = require("tap") +var fs = require("fs") +var rimraf = require("rimraf") +var fixtures = path.resolve(__dirname, "fixtures") + +var chars = ['a', 'b', 'c'] +var dirs = [] + +for (var i = 0; i < 3; i ++) { + for (var j = 0; j < 3; j ++) { + for (var k = 0; k < 3; k ++) { + dirs.push(chars[i] + '/' + chars[j] + '/' + chars[k]) + } + } +} + +var files = [] + +for (var i = 0; i < 3; i ++) { + for (var j = 0; j < 3; j ++) { + for (var k = 0; k < 3; k ++) { + files.push(chars[i] + chars[j] + chars[k]) + files.push('.' + chars[i] + chars[j] + chars[k]) + } + } +} + +tap.test("remove fixtures", function (t) { + rimraf(path.resolve(__dirname, "fixtures"), function (er) { + t.ifError(er, "remove fixtures") + t.end() + }) +}) + +tap.test("create fixtures", function (t) { + dirs.forEach(function (dir) { + dir = path.resolve(fixtures, dir) + t.test("mkdir "+dir, function (t) { + mkdirp(dir, function (er) { + t.ifError(er, "mkdir "+dir) + if (er) return t.end() + + files.forEach(function (file) { + file = path.resolve(dir, file) + t.test("writeFile "+file, function (t) { + fs.writeFile(file, path.basename(file), function (er) { + t.ifError(er, "writing "+file) + t.end() + }) + }) + }) + t.end() + }) + }) + }) + t.end() +}) + diff --git a/node_modules/fstream-npm/node_modules/fstream-ignore/test/basic.js b/node_modules/fstream-npm/node_modules/fstream-ignore/test/basic.js new file mode 100644 index 000000000..3718076ee --- /dev/null +++ b/node_modules/fstream-npm/node_modules/fstream-ignore/test/basic.js @@ -0,0 +1,28 @@ +var IgnoreFile = require("../") + +// set the ignores just for this test +var c = require("./common.js") +c.ignores({ "a/.basic-ignore": ["b/", "aca"] }) + +// the files that we expect to not see +var notAllowed = + [ /^\/a\/b\/.*/ + , /^\/a\/.*\/aca$/ ] + + +require("tap").test("basic ignore rules", function (t) { + t.pass("start") + + IgnoreFile({ path: __dirname + "/fixtures" + , ignoreFiles: [".basic-ignore"] }) + .on("ignoreFile", function (e) { + console.error("ignore file!", e) + }) + .on("child", function (e) { + var p = e.path.substr(e.root.path.length) + notAllowed.forEach(function (na) { + t.dissimilar(p, na) + }) + }) + .on("close", t.end.bind(t)) +}) diff --git a/node_modules/fstream-npm/node_modules/fstream-ignore/test/common.js b/node_modules/fstream-npm/node_modules/fstream-ignore/test/common.js new file mode 100644 index 000000000..0e6cd989c --- /dev/null +++ b/node_modules/fstream-npm/node_modules/fstream-ignore/test/common.js @@ -0,0 +1,40 @@ +if (require.main === module) { + console.log("0..1") + console.log("ok 1 trivial pass") + return +} + +var fs = require("fs") +var path = require("path") +var rimraf = require("rimraf") + +exports.ignores = ignores +exports.writeIgnoreFile = writeIgnoreFile +exports.writeIgnores = writeIgnores +exports.clearIgnores = clearIgnores + +function writeIgnoreFile (file, rules) { + file = path.resolve(__dirname, "fixtures", file) + if (Array.isArray(rules)) { + rules = rules.join("\n") + } + fs.writeFileSync(file, rules) + console.error(file, rules) +} + +function writeIgnores (set) { + Object.keys(set).forEach(function (f) { + writeIgnoreFile(f, set[f]) + }) +} + +function clearIgnores (set) { + Object.keys(set).forEach(function (file) { + fs.unlinkSync(path.resolve(__dirname, "fixtures", file)) + }) +} + +function ignores (set) { + writeIgnores(set) + process.on("exit", clearIgnores.bind(null, set)) +} diff --git a/node_modules/fstream-npm/node_modules/fstream-ignore/test/ignore-most.js b/node_modules/fstream-npm/node_modules/fstream-ignore/test/ignore-most.js new file mode 100644 index 000000000..43eec4b54 --- /dev/null +++ b/node_modules/fstream-npm/node_modules/fstream-ignore/test/ignore-most.js @@ -0,0 +1,41 @@ +// ignore most things +var IgnoreFile = require("../") + +// set the ignores just for this test +var c = require("./common.js") +c.ignores({ ".ignore": ["*", "!a/b/c/.abc", "!/c/b/a/cba"] }) + +// the only files we expect to see +var expected = + [ "/a/b/c/.abc" + , "/a" + , "/a/b" + , "/a/b/c" + , "/c/b/a/cba" + , "/c" + , "/c/b" + , "/c/b/a" ] + +require("tap").test("basic ignore rules", function (t) { + t.pass("start") + + IgnoreFile({ path: __dirname + "/fixtures" + , ignoreFiles: [".ignore"] }) + .on("ignoreFile", function (e) { + console.error("ignore file!", e) + }) + .on("child", function (e) { + var p = e.path.substr(e.root.path.length) + var i = expected.indexOf(p) + if (i === -1) { + t.fail("unexpected file found", {file: p}) + } else { + t.pass(p) + expected.splice(i, 1) + } + }) + .on("close", function () { + t.notOk(expected.length, "all expected files should be seen") + t.end() + }) +}) diff --git a/node_modules/fstream-npm/node_modules/fstream-ignore/test/nested-ignores.js b/node_modules/fstream-npm/node_modules/fstream-ignore/test/nested-ignores.js new file mode 100644 index 000000000..a9ede59ca --- /dev/null +++ b/node_modules/fstream-npm/node_modules/fstream-ignore/test/nested-ignores.js @@ -0,0 +1,51 @@ +// ignore most things +var IgnoreFile = require("../") + +// set the ignores just for this test +var c = require("./common.js") +c.ignores( + { ".ignore": ["*", "a", "c", "!a/b/c/.abc", "!/c/b/a/cba"] + , "a/.ignore": [ "!*", ".ignore" ] // unignore everything + , "a/a/.ignore": [ "*" ] // re-ignore everything + , "a/b/.ignore": [ "*", "!/c/.abc" ] // original unignore + , "a/c/.ignore": [ "*" ] // ignore everything again + , "c/b/a/.ignore": [ "!cba", "!.cba", "!/a{bc,cb}" ] + }) + +// the only files we expect to see +var expected = + [ "/a" + , "/a/a" + , "/a/b" + , "/a/b/c" + , "/a/b/c/.abc" + , "/a/c" + , "/c" + , "/c/b" + , "/c/b/a" + , "/c/b/a/cba" + , "/c/b/a/.cba" + , "/c/b/a/abc" + , "/c/b/a/acb" ] + +require("tap").test("basic ignore rules", function (t) { + t.pass("start") + + IgnoreFile({ path: __dirname + "/fixtures" + , ignoreFiles: [".ignore"] }) + .on("child", function (e) { + var p = e.path.substr(e.root.path.length) + var i = expected.indexOf(p) + if (i === -1) { + console.log("not ok "+p) + t.fail("unexpected file found", {found: p}) + } else { + t.pass(p) + expected.splice(i, 1) + } + }) + .on("close", function () { + t.deepEqual(expected, [], "all expected files should be seen") + t.end() + }) +}) diff --git a/node_modules/fstream-npm/node_modules/fstream-ignore/test/unignore-child.js b/node_modules/fstream-npm/node_modules/fstream-ignore/test/unignore-child.js new file mode 100644 index 000000000..5812354df --- /dev/null +++ b/node_modules/fstream-npm/node_modules/fstream-ignore/test/unignore-child.js @@ -0,0 +1,38 @@ +// ignore most things +var IgnoreFile = require("../") + +// set the ignores just for this test +var c = require("./common.js") +c.ignores({ ".ignore": ["*", "a", "c", "!a/b/c/.abc", "!/c/b/a/cba"] }) + +// the only files we expect to see +var expected = + [ "/a/b/c/.abc" + , "/a" + , "/a/b" + , "/a/b/c" + , "/c/b/a/cba" + , "/c" + , "/c/b" + , "/c/b/a" ] + +require("tap").test("basic ignore rules", function (t) { + t.pass("start") + + IgnoreFile({ path: __dirname + "/fixtures" + , ignoreFiles: [".ignore"] }) + .on("child", function (e) { + var p = e.path.substr(e.root.path.length) + var i = expected.indexOf(p) + if (i === -1) { + t.fail("unexpected file found", {f: p}) + } else { + t.pass(p) + expected.splice(i, 1) + } + }) + .on("close", function () { + t.notOk(expected.length, "all expected files should be seen") + t.end() + }) +}) diff --git a/node_modules/fstream-npm/node_modules/fstream-ignore/test/zz-cleanup.js b/node_modules/fstream-npm/node_modules/fstream-ignore/test/zz-cleanup.js new file mode 100644 index 000000000..82f064a42 --- /dev/null +++ b/node_modules/fstream-npm/node_modules/fstream-ignore/test/zz-cleanup.js @@ -0,0 +1,10 @@ +var tap = require("tap") +, rimraf = require("rimraf") +, path = require("path") + +tap.test("remove fixtures", function (t) { + rimraf(path.resolve(__dirname, "fixtures"), function (er) { + t.ifError(er, "remove fixtures") + t.end() + }) +}) diff --git a/node_modules/fstream-npm/package.json b/node_modules/fstream-npm/package.json index fa46c74e6..edb192248 100644 --- a/node_modules/fstream-npm/package.json +++ b/node_modules/fstream-npm/package.json @@ -6,7 +6,7 @@ }, "name": "fstream-npm", "description": "fstream class for creating npm packages", - "version": "0.1.0", + "version": "0.1.1", "repository": { "type": "git", "url": "git://github.com/isaacs/fstream-npm.git" @@ -17,19 +17,7 @@ "inherits": "" }, "license": "BSD", - "_npmUser": { - "name": "isaacs", - "email": "i@izs.me" - }, - "_id": "fstream-npm@0.1.0", - "devDependencies": {}, - "optionalDependencies": {}, - "engines": { - "node": "*" - }, - "_engineSupported": true, - "_npmVersion": "1.1.23", - "_nodeVersion": "v0.7.10-pre", - "_defaultsLoaded": true, + "readme": "# fstream-npm\n\nThis is an fstream DirReader class that will read a directory and filter\nthings according to the semantics of what goes in an npm package.\n\nFor example:\n\n```javascript\n// This will print out all the files that would be included\n// by 'npm publish' or 'npm install' of this directory.\n\nvar FN = require(\"fstream-npm\")\nFN({ path: \"./\" })\n .on(\"child\", function (e) {\n console.error(e.path.substr(e.root.path.length + 1))\n })\n```\n\n", + "_id": "fstream-npm@0.1.1", "_from": "fstream-npm@0.1" } |