Permalink
Browse files

Some examples

  • Loading branch information...
isaacs committed Mar 27, 2012
1 parent 94dd185 commit acddadd3e574148100034900e1b80d1c801cab7f
Showing with 109 additions and 5 deletions.
  1. +13 −0 example/bundle.js
  2. +19 −0 example/dir-tar.js
  3. +25 −0 example/dir.js
  4. +8 −5 example/example.js
  5. +19 −0 example/ig-tar.js
  6. +25 −0 example/tar.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.path.length + 1))
+ e.on("package", bundleIt)
+ })
+
+function bundleIt (p) {
+ p.bundleDependencies = Object.keys(p.dependencies || {})
+}
+
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)
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")
+ })
View
@@ -1,9 +1,12 @@
+// this will show what ends up in the fstream-npm package
var P = require("../")
P({ path: "./" })
- .on("package", function () {
- console.error(this.package)
+ .on("package", function (p) {
+ console.error("package", p)
})
- .on("child", function (e) {
- console.error(e.path.substr(e.root.path.length + 1))
+ .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))
})
-
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)
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)

0 comments on commit acddadd

Please sign in to comment.