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>2015-12-04 01:58:40 +0300
committerForrest L Norvell <forrest@npmjs.com>2015-12-04 01:58:40 +0300
commit8347a308ef0d2cf0f58f96bba3635af642ec611f (patch)
treed87eb38a91e874b98e11549dd70611d4d5cc902b /node_modules/fs-write-stream-atomic
parent641a93bd66a6aa4edf2d6167344b50d1a2afb593 (diff)
fs-write-stream-atomic@1.0.5
Fixes: #10629 Credit: @othiym23
Diffstat (limited to 'node_modules/fs-write-stream-atomic')
-rw-r--r--node_modules/fs-write-stream-atomic/.npmignore3
-rw-r--r--node_modules/fs-write-stream-atomic/.travis.yml11
-rw-r--r--node_modules/fs-write-stream-atomic/index.js38
-rw-r--r--node_modules/fs-write-stream-atomic/package.json99
-rw-r--r--node_modules/fs-write-stream-atomic/test/basic.js44
-rw-r--r--node_modules/fs-write-stream-atomic/test/toolong.js14
6 files changed, 131 insertions, 78 deletions
diff --git a/node_modules/fs-write-stream-atomic/.npmignore b/node_modules/fs-write-stream-atomic/.npmignore
new file mode 100644
index 000000000..2f24c57c3
--- /dev/null
+++ b/node_modules/fs-write-stream-atomic/.npmignore
@@ -0,0 +1,3 @@
+node_modules/
+coverage/
+.nyc_output/
diff --git a/node_modules/fs-write-stream-atomic/.travis.yml b/node_modules/fs-write-stream-atomic/.travis.yml
new file mode 100644
index 000000000..689466252
--- /dev/null
+++ b/node_modules/fs-write-stream-atomic/.travis.yml
@@ -0,0 +1,11 @@
+language: node_js
+sudo: false
+before_install:
+ - "npm -g install npm"
+node_js:
+ - "0.8"
+ - "0.10"
+ - "0.12"
+ - "iojs"
+ - "4"
+ - "5"
diff --git a/node_modules/fs-write-stream-atomic/index.js b/node_modules/fs-write-stream-atomic/index.js
index d86b8c673..949250531 100644
--- a/node_modules/fs-write-stream-atomic/index.js
+++ b/node_modules/fs-write-stream-atomic/index.js
@@ -1,29 +1,29 @@
var fs = require('graceful-fs')
var util = require('util')
-var crypto = require('crypto')
+var MurmurHash3 = require('imurmurhash')
-function md5hex () {
- var hash = crypto.createHash('md5')
- for (var ii=0; ii<arguments.length; ++ii) {
- hash.update(''+arguments[ii])
+function murmurhex () {
+ var hash = MurmurHash3('')
+ for (var ii = 0; ii < arguments.length; ++ii) {
+ hash.hash(hash + arguments[ii])
}
- return hash.digest('hex')
+ return hash.result()
}
-var invocations = 0;
+var invocations = 0
function getTmpname (filename) {
- return filename + "." + md5hex(__filename, process.pid, ++invocations)
+ return filename + '.' + murmurhex(__filename, process.pid, ++invocations)
}
module.exports = WriteStream
util.inherits(WriteStream, fs.WriteStream)
function WriteStream (path, options) {
- if (!options)
- options = {}
+ if (!options) options = {}
- if (!(this instanceof WriteStream))
+ if (!(this instanceof WriteStream)) {
return new WriteStream(path, options)
+ }
this.__atomicTarget = path
this.__atomicChown = options.chown
@@ -49,26 +49,26 @@ function cleanupSync () {
// When we *would* emit 'close' or 'finish', instead do our stuff
WriteStream.prototype.emit = function (ev) {
- if (ev === 'error')
- cleanupSync.call(this)
+ if (ev === 'error') cleanupSync.call(this)
- if (ev !== 'close' && ev !== 'finish')
+ if (ev !== 'close' && ev !== 'finish') {
return fs.WriteStream.prototype.emit.apply(this, arguments)
+ }
// 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)
+ if (er) cleanup.call(this, er)
}.bind(this))
}
}
}
-function atomicDoStuff(cb) {
- if (this.__atomicDidStuff)
+function atomicDoStuff (cb) {
+ if (this.__atomicDidStuff) {
throw new Error('Already did atomic move-into-place')
+ }
this.__atomicDidStuff = true
if (this.__atomicChown) {
@@ -89,7 +89,7 @@ function moveIntoPlace (cb) {
// 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() {
+ 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 a226dbe48..e61078ede 100644
--- a/node_modules/fs-write-stream-atomic/package.json
+++ b/node_modules/fs-write-stream-atomic/package.json
@@ -1,48 +1,65 @@
{
- "name": "fs-write-stream-atomic",
- "version": "1.0.4",
- "description": "Like `fs.createWriteStream(...)`, but atomic.",
- "main": "index.js",
- "directories": {
- "test": "test"
- },
- "dependencies": {
- "graceful-fs": "^4.1.2"
- },
- "devDependencies": {
- "tap": "^1.2.0"
- },
- "scripts": {
- "test": "tap test/*.js"
+ "_args": [
+ [
+ "fs-write-stream-atomic@^1.0.5",
+ "/Users/ogd/Documents/projects/npm/npm"
+ ]
+ ],
+ "_from": "fs-write-stream-atomic@>=1.0.5 <2.0.0",
+ "_id": "fs-write-stream-atomic@1.0.5",
+ "_inCache": true,
+ "_installable": true,
+ "_location": "/fs-write-stream-atomic",
+ "_nodeVersion": "5.1.0",
+ "_npmUser": {
+ "email": "ogd@aoaioxxysz.net",
+ "name": "othiym23"
},
- "repository": {
- "type": "git",
- "url": "git+https://github.com/npm/fs-write-stream-atomic.git"
+ "_npmVersion": "3.5.1",
+ "_phantomChildren": {},
+ "_requested": {
+ "name": "fs-write-stream-atomic",
+ "raw": "fs-write-stream-atomic@^1.0.5",
+ "rawSpec": "^1.0.5",
+ "scope": null,
+ "spec": ">=1.0.5 <2.0.0",
+ "type": "range"
},
+ "_requiredBy": [
+ "/"
+ ],
+ "_shasum": "862a4dabdffcafabfc16499458e37310c39925f6",
+ "_shrinkwrap": null,
+ "_spec": "fs-write-stream-atomic@^1.0.5",
+ "_where": "/Users/ogd/Documents/projects/npm/npm",
"author": {
- "name": "Isaac Z. Schlueter",
"email": "i@izs.me",
+ "name": "Isaac Z. Schlueter",
"url": "http://blog.izs.me/"
},
- "license": "ISC",
"bugs": {
"url": "https://github.com/npm/fs-write-stream-atomic/issues"
},
- "homepage": "https://github.com/npm/fs-write-stream-atomic",
- "gitHead": "6ca2651b913149543c5390c6c4f7d370bdca42b5",
- "_id": "fs-write-stream-atomic@1.0.4",
- "_shasum": "c1ea55889f036ceebdead7d1055edbad998fe5e9",
- "_from": "fs-write-stream-atomic@>=1.0.4 <1.1.0",
- "_npmVersion": "2.14.3",
- "_nodeVersion": "2.2.2",
- "_npmUser": {
- "name": "zkat",
- "email": "kat@sykosomatic.org"
+ "dependencies": {
+ "graceful-fs": "^4.1.2",
+ "imurmurhash": "^0.1.4"
+ },
+ "description": "Like `fs.createWriteStream(...)`, but atomic.",
+ "devDependencies": {
+ "standard": "^5.4.1",
+ "tap": "^2.3.1"
+ },
+ "directories": {
+ "test": "test"
},
"dist": {
- "shasum": "c1ea55889f036ceebdead7d1055edbad998fe5e9",
- "tarball": "http://registry.npmjs.org/fs-write-stream-atomic/-/fs-write-stream-atomic-1.0.4.tgz"
+ "shasum": "862a4dabdffcafabfc16499458e37310c39925f6",
+ "tarball": "http://registry.npmjs.org/fs-write-stream-atomic/-/fs-write-stream-atomic-1.0.5.tgz"
},
+ "gitHead": "1bc752bf0e0d5b7aaaad7be696dbc0e4ea64258c",
+ "homepage": "https://github.com/npm/fs-write-stream-atomic",
+ "license": "ISC",
+ "main": "index.js",
"maintainers": [
{
"name": "iarna",
@@ -50,12 +67,26 @@
},
{
"name": "isaacs",
- "email": "isaacs@npmjs.com"
+ "email": "i@izs.me"
+ },
+ {
+ "name": "othiym23",
+ "email": "ogd@aoaioxxysz.net"
},
{
"name": "zkat",
"email": "kat@sykosomatic.org"
}
],
- "_resolved": "https://registry.npmjs.org/fs-write-stream-atomic/-/fs-write-stream-atomic-1.0.4.tgz"
+ "name": "fs-write-stream-atomic",
+ "optionalDependencies": {},
+ "readme": "ERROR: No README data found!",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/npm/fs-write-stream-atomic.git"
+ },
+ "scripts": {
+ "test": "standard && tap --coverage test/*.js"
+ },
+ "version": "1.0.5"
}
diff --git a/node_modules/fs-write-stream-atomic/test/basic.js b/node_modules/fs-write-stream-atomic/test/basic.js
index 159c596ab..2dae137a6 100644
--- a/node_modules/fs-write-stream-atomic/test/basic.js
+++ b/node_modules/fs-write-stream-atomic/test/basic.js
@@ -19,31 +19,33 @@ test('basic', function (t) {
}
var verifierCalled = 0
- function verifier (ev) { return function () {
- if (ev === 'close')
- t.equal(this.__emittedFinish, true)
- else {
- this.__emittedFinish = true
- t.equal(ev, 'finish')
- }
+ function verifier (ev) {
+ return function () {
+ if (ev === 'close') {
+ t.equal(this.__emittedFinish, true)
+ } else {
+ this.__emittedFinish = true
+ t.equal(ev, 'finish')
+ }
- // make sure that one of the atomic streams won.
- var res = fs.readFileSync(target, 'utf8')
- var lines = res.trim().split(/\n/)
- lines.forEach(function (line) {
- var first = lines[0].match(/\d+$/)[0]
- var cur = line.match(/\d+$/)[0]
- t.equal(cur, first)
- })
+ // make sure that one of the atomic streams won.
+ var res = fs.readFileSync(target, 'utf8')
+ var lines = res.trim().split(/\n/)
+ lines.forEach(function (line) {
+ var first = lines[0].match(/\d+$/)[0]
+ var cur = line.match(/\d+$/)[0]
+ t.equal(cur, first)
+ })
- var resExpr = /^first write \d+\nsecond write \d+\nthird write \d+\nfinal write \d+\n$/
- t.similar(res, resExpr)
+ var resExpr = /^first write \d+\nsecond write \d+\nthird write \d+\nfinal write \d+\n$/
+ t.similar(res, resExpr)
- // should be called once for each close, and each finish
- if (++verifierCalled === n * 2) {
- t.end()
+ // should be called once for each close, and each finish
+ if (++verifierCalled === n * 2) {
+ t.end()
+ }
}
- }}
+ }
// now write something to each stream.
streams.forEach(function (stream, i) {
diff --git a/node_modules/fs-write-stream-atomic/test/toolong.js b/node_modules/fs-write-stream-atomic/test/toolong.js
index a1e5b714a..be77f99cf 100644
--- a/node_modules/fs-write-stream-atomic/test/toolong.js
+++ b/node_modules/fs-write-stream-atomic/test/toolong.js
@@ -2,7 +2,7 @@ var path = require('path')
var test = require('tap').test
var writeStream = require('../index.js')
-function repeat(times, string) {
+function repeat (times, string) {
var output = ''
for (var ii = 0; ii < times; ++ii) {
output += string
@@ -10,19 +10,25 @@ function repeat(times, string) {
return output
}
-var target = path.resolve(__dirname, repeat(1000,'test'))
+var target = path.resolve(__dirname, repeat(1000, 'test'))
test('name too long', function (t) {
+ // 0.8 streams smh
+ if (process.version.indexOf('v0.8') !== -1) {
+ t.plan(1)
+ } else {
+ t.plan(2)
+ }
var stream = writeStream(target)
var hadError = false
stream.on('error', function (er) {
if (!hadError) {
- t.is(er.code, 'ENAMETOOLONG', target.length + " character name results in ENAMETOOLONG")
+ t.is(er.code, 'ENAMETOOLONG', target.length + ' character name results in ENAMETOOLONG')
hadError = true
}
})
stream.on('close', function () {
- t.end()
+ t.ok(hadError, 'got error before close')
})
stream.end()
})