Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorForrest L Norvell <forrest@npmjs.com>2014-09-30 04:59:49 +0400
committerForrest L Norvell <forrest@npmjs.com>2014-09-30 05:11:46 +0400
commitb8c3c74a3c963564233204161cc263e0912c930b (patch)
tree83dfba8dd193717d0471976386e85f485d7cee66 /node_modules/fs-write-stream-atomic
parent8b58ad09b719295461167a34f666c5aa4d6e26f2 (diff)
fs-write-stream-atomic@1.0.2
Now works with streams1 fs.WriteStreams.
Diffstat (limited to 'node_modules/fs-write-stream-atomic')
-rw-r--r--node_modules/fs-write-stream-atomic/index.js23
-rw-r--r--node_modules/fs-write-stream-atomic/package.json18
2 files changed, 23 insertions, 18 deletions
diff --git a/node_modules/fs-write-stream-atomic/index.js b/node_modules/fs-write-stream-atomic/index.js
index 70b22ba8c..42a9a8825 100644
--- a/node_modules/fs-write-stream-atomic/index.js
+++ b/node_modules/fs-write-stream-atomic/index.js
@@ -55,15 +55,15 @@ WriteStream.prototype.emit = function (ev) {
if (ev !== 'close' && ev !== 'finish')
return fs.WriteStream.prototype.emit.apply(this, arguments)
- if (ev === 'finish') {
- atomicDoStuff.call(this, function (er) {
- if (er)
- cleanup.call(this, er)
- else
- fs.WriteStream.prototype.emit.call(this, 'finish')
- }.bind(this))
+ // We handle emitting finish and close after the rename.
+ if (ev === 'close' || ev === 'finish') {
+ if (!this.__atomicDidStuff) {
+ atomicDoStuff.call(this, function (er) {
+ if (er)
+ cleanup.call(this, er)
+ }.bind(this))
+ }
}
- // close will be emitted later, once we do the rename
}
function atomicDoStuff(cb) {
@@ -86,6 +86,11 @@ function atomicDoStuff(cb) {
function moveIntoPlace (cb) {
fs.rename(this.__atomicTmp, this.__atomicTarget, function (er) {
cb(er)
- fs.WriteStream.prototype.emit.call(this, 'close')
+ // emit finish, and then close on the next tick
+ // This makes finish/close consistent across Node versions also.
+ fs.WriteStream.prototype.emit.call(this, 'finish')
+ process.nextTick(function() {
+ fs.WriteStream.prototype.emit.call(this, 'close')
+ }.bind(this))
}.bind(this))
}
diff --git a/node_modules/fs-write-stream-atomic/package.json b/node_modules/fs-write-stream-atomic/package.json
index 4a6594d13..5cdd1a2e0 100644
--- a/node_modules/fs-write-stream-atomic/package.json
+++ b/node_modules/fs-write-stream-atomic/package.json
@@ -1,6 +1,6 @@
{
"name": "fs-write-stream-atomic",
- "version": "1.0.1",
+ "version": "1.0.2",
"description": "Like `fs.createWriteStream(...)`, but atomic.",
"main": "index.js",
"directories": {
@@ -29,11 +29,11 @@
"url": "https://github.com/npm/fs-write-stream-atomic/issues"
},
"homepage": "https://github.com/npm/fs-write-stream-atomic",
- "gitHead": "7db0e8159270278b097789bcefb061b5c5fa7161",
- "_id": "fs-write-stream-atomic@1.0.1",
- "_shasum": "5e424a143d9d29a700bb409729d6612b678f05ac",
- "_from": "fs-write-stream-atomic@>=1.0.1 <2.0.0",
- "_npmVersion": "2.0.2",
+ "gitHead": "86b111ed1d5db84e8a9680986ef7917036b9c97b",
+ "_id": "fs-write-stream-atomic@1.0.2",
+ "_shasum": "fe0c6cec75256072b2fef8180d97e309fe3f5efb",
+ "_from": "fs-write-stream-atomic@>=1.0.2 <1.1.0",
+ "_npmVersion": "2.1.0",
"_nodeVersion": "0.10.31",
"_npmUser": {
"name": "isaacs",
@@ -46,8 +46,8 @@
}
],
"dist": {
- "shasum": "5e424a143d9d29a700bb409729d6612b678f05ac",
- "tarball": "http://registry.npmjs.org/fs-write-stream-atomic/-/fs-write-stream-atomic-1.0.1.tgz"
+ "shasum": "fe0c6cec75256072b2fef8180d97e309fe3f5efb",
+ "tarball": "http://registry.npmjs.org/fs-write-stream-atomic/-/fs-write-stream-atomic-1.0.2.tgz"
},
- "_resolved": "https://registry.npmjs.org/fs-write-stream-atomic/-/fs-write-stream-atomic-1.0.1.tgz"
+ "_resolved": "https://registry.npmjs.org/fs-write-stream-atomic/-/fs-write-stream-atomic-1.0.2.tgz"
}