Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fstream-npm@0.1.1

  • Loading branch information...
commit 6589a195c4e5f5e8e1414d21ab286bca52a30b6c 1 parent 8fc010b
isaacs isaacs authored
Showing with 415 additions and 27 deletions.
  1. +13 −0 node_modules/fstream-npm/example/bundle.js
  2. +19 −0 node_modules/fstream-npm/example/dir-tar.js
  3. +25 −0 node_modules/fstream-npm/example/dir.js
  4. +12 −0 node_modules/fstream-npm/example/example.js
  5. +19 −0 node_modules/fstream-npm/example/ig-tar.js
  6. +25 −0 node_modules/fstream-npm/example/tar.js
  7. +3 −0  node_modules/fstream-npm/fstream-npm.js
  8. +13 −0 node_modules/fstream-npm/node_modules/fstream-ignore/example/basic.js
  9. +1 −12 node_modules/fstream-npm/node_modules/fstream-ignore/package.json
  10. +2 −0  node_modules/fstream-npm/node_modules/fstream-ignore/test/.ignore
  11. +1 −0  node_modules/fstream-npm/node_modules/fstream-ignore/test/.npmignore
  12. +71 −0 node_modules/fstream-npm/node_modules/fstream-ignore/test/00-setup.js
  13. +28 −0 node_modules/fstream-npm/node_modules/fstream-ignore/test/basic.js
  14. +40 −0 node_modules/fstream-npm/node_modules/fstream-ignore/test/common.js
  15. +41 −0 node_modules/fstream-npm/node_modules/fstream-ignore/test/ignore-most.js
  16. +51 −0 node_modules/fstream-npm/node_modules/fstream-ignore/test/nested-ignores.js
  17. +38 −0 node_modules/fstream-npm/node_modules/fstream-ignore/test/unignore-child.js
  18. +10 −0 node_modules/fstream-npm/node_modules/fstream-ignore/test/zz-cleanup.js
  19. +3 −15 node_modules/fstream-npm/package.json
13 node_modules/fstream-npm/example/bundle.js
View
@@ -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 || {})
+}
+
19 node_modules/fstream-npm/example/dir-tar.js
View
@@ -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)
25 node_modules/fstream-npm/example/dir.js
View
@@ -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")
+ })
12 node_modules/fstream-npm/example/example.js
View
@@ -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))
+ })
19 node_modules/fstream-npm/example/ig-tar.js
View
@@ -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)
25 node_modules/fstream-npm/example/tar.js
View
@@ -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)
3  node_modules/fstream-npm/fstream-npm.js
View
@@ -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
13 node_modules/fstream-npm/node_modules/fstream-ignore/example/basic.js
View
@@ -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)
+}
13 node_modules/fstream-npm/node_modules/fstream-ignore/package.json
View
@@ -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"
}
2  node_modules/fstream-npm/node_modules/fstream-ignore/test/.ignore
View
@@ -0,0 +1,2 @@
+.gitignore
+.*.swp
1  node_modules/fstream-npm/node_modules/fstream-ignore/test/.npmignore
View
@@ -0,0 +1 @@
+*/a
71 node_modules/fstream-npm/node_modules/fstream-ignore/test/00-setup.js
View
@@ -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()
+})
+
28 node_modules/fstream-npm/node_modules/fstream-ignore/test/basic.js
View
@@ -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))
+})
40 node_modules/fstream-npm/node_modules/fstream-ignore/test/common.js
View
@@ -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))
+}
41 node_modules/fstream-npm/node_modules/fstream-ignore/test/ignore-most.js
View
@@ -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()
+ })
+})
51 node_modules/fstream-npm/node_modules/fstream-ignore/test/nested-ignores.js
View
@@ -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()
+ })
+})
38 node_modules/fstream-npm/node_modules/fstream-ignore/test/unignore-child.js
View
@@ -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()
+ })
+})
10 node_modules/fstream-npm/node_modules/fstream-ignore/test/zz-cleanup.js
View
@@ -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()
+ })
+})
18 node_modules/fstream-npm/package.json
View
@@ -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"
}
Please sign in to comment.
Something went wrong with that request. Please try again.