diff options
author | isaacs <i@izs.me> | 2012-12-28 04:58:39 +0400 |
---|---|---|
committer | isaacs <i@izs.me> | 2012-12-28 04:58:39 +0400 |
commit | 11e8e4ec778d087271edacfc84baba5331e93a1a (patch) | |
tree | 788a775a4ddd8b412eef13990957e35b8ac075a7 | |
parent | 115d67d0dbbf4b3cab3ef5c2d93cb52a6e795f81 (diff) |
fstream@0.1.21
-rw-r--r-- | node_modules/fstream/lib/file-writer.js | 5 | ||||
-rw-r--r-- | node_modules/fstream/lib/proxy-writer.js | 4 | ||||
-rw-r--r-- | node_modules/fstream/package.json | 6 |
3 files changed, 10 insertions, 5 deletions
diff --git a/node_modules/fstream/lib/file-writer.js b/node_modules/fstream/lib/file-writer.js index 4ed0c9c6c..681146258 100644 --- a/node_modules/fstream/lib/file-writer.js +++ b/node_modules/fstream/lib/file-writer.js @@ -36,12 +36,15 @@ FileWriter.prototype._create = function () { me._stream = fs.createWriteStream(me._path, so) me._stream.on("open", function (fd) { + // console.error("FW open", me._buffer, me._path) me.ready = true me._buffer.forEach(function (c) { if (c === EOF) me._stream.end() else me._stream.write(c) }) me.emit("ready") + // give this a kick just in case it needs it. + me.emit("drain") }) me._stream.on("drain", function () { me.emit("drain") }) @@ -58,6 +61,8 @@ FileWriter.prototype.write = function (c) { me._bytesWritten += c.length if (!me.ready) { + if (!Buffer.isBuffer(c) && typeof c !== 'string') + throw new Error('invalid write data') me._buffer.push(c) return false } diff --git a/node_modules/fstream/lib/proxy-writer.js b/node_modules/fstream/lib/proxy-writer.js index 2c78fc673..b0476633a 100644 --- a/node_modules/fstream/lib/proxy-writer.js +++ b/node_modules/fstream/lib/proxy-writer.js @@ -71,7 +71,7 @@ ProxyWriter.prototype._addProxy = function (proxy) { var calls = me._buffer calls.forEach(function (c) { // console.error("~~ ~~ proxy buffered call", c[0], c[1]) - proxy[c[0]].call(proxy, c[1]) + proxy[c[0]].apply(proxy, c[1]) }) me._buffer.length = 0 if (me._needsDrain) me.emit("drain") @@ -102,7 +102,7 @@ ProxyWriter.prototype.write = function (c) { ProxyWriter.prototype.end = function (c) { // console.error("~~ proxy end") if (!this._proxy) { - this._buffer.push(["end", c]) + this._buffer.push(["end", [c]]) return false } return this._proxy.end(c) diff --git a/node_modules/fstream/package.json b/node_modules/fstream/package.json index e15551ba9..1d3faaff1 100644 --- a/node_modules/fstream/package.json +++ b/node_modules/fstream/package.json @@ -6,7 +6,7 @@ }, "name": "fstream", "description": "Advanced file system stream things", - "version": "0.1.20", + "version": "0.1.21", "repository": { "type": "git", "url": "git://github.com/isaacs/fstream.git" @@ -30,6 +30,6 @@ "license": "BSD", "readme": "Like FS streams, but with stat on them, and supporting directories and\nsymbolic links, as well as normal files. Also, you can use this to set\nthe stats on a file, even if you don't change its contents, or to create\na symlink, etc.\n\nSo, for example, you can \"write\" a directory, and it'll call `mkdir`. You\ncan specify a uid and gid, and it'll call `chown`. You can specify a\n`mtime` and `atime`, and it'll call `utimes`. You can call it a symlink\nand provide a `linkpath` and it'll call `symlink`.\n\nNote that it won't automatically resolve symbolic links. So, if you\ncall `fstream.Reader('/some/symlink')` then you'll get an object\nthat stats and then ends immediately (since it has no data). To follow\nsymbolic links, do this: `fstream.Reader({path:'/some/symlink', follow:\ntrue })`.\n\nThere are various checks to make sure that the bytes emitted are the\nsame as the intended size, if the size is set.\n\n## Examples\n\n```javascript\nfstream\n .Writer({ path: \"path/to/file\"\n , mode: 0755\n , size: 6\n })\n .write(\"hello\\n\")\n .end()\n```\n\nThis will create the directories if they're missing, and then write\n`hello\\n` into the file, chmod it to 0755, and assert that 6 bytes have\nbeen written when it's done.\n\n```javascript\nfstream\n .Writer({ path: \"path/to/file\"\n , mode: 0755\n , size: 6\n , flags: \"a\"\n })\n .write(\"hello\\n\")\n .end()\n```\n\nYou can pass flags in, if you want to append to a file.\n\n```javascript\nfstream\n .Writer({ path: \"path/to/symlink\"\n , linkpath: \"./file\"\n , SymbolicLink: true\n , mode: \"0755\" // octal strings supported\n })\n .end()\n```\n\nIf isSymbolicLink is a function, it'll be called, and if it returns\ntrue, then it'll treat it as a symlink. If it's not a function, then\nany truish value will make a symlink, or you can set `type:\n'SymbolicLink'`, which does the same thing.\n\nNote that the linkpath is relative to the symbolic link location, not\nthe parent dir or cwd.\n\n```javascript\nfstream\n .Reader(\"path/to/dir\")\n .pipe(fstream.Writer(\"path/to/other/dir\"))\n```\n\nThis will do like `cp -Rp path/to/dir path/to/other/dir`. If the other\ndir exists and isn't a directory, then it'll emit an error. It'll also\nset the uid, gid, mode, etc. to be identical. In this way, it's more\nlike `rsync -a` than simply a copy.\n", "readmeFilename": "README.md", - "_id": "fstream@0.1.20", - "_from": "fstream@~0.1.17" + "_id": "fstream@0.1.21", + "_from": "fstream@latest" } |