aboutsummaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/write-file-atomic
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/write-file-atomic')
-rw-r--r--deps/npm/node_modules/write-file-atomic/.npmignore4
-rw-r--r--deps/npm/node_modules/write-file-atomic/.travis.yml11
-rw-r--r--deps/npm/node_modules/write-file-atomic/LICENSE1
-rw-r--r--deps/npm/node_modules/write-file-atomic/README.md2
-rw-r--r--deps/npm/node_modules/write-file-atomic/index.js60
-rw-r--r--deps/npm/node_modules/write-file-atomic/package.json68
-rw-r--r--deps/npm/node_modules/write-file-atomic/test/basic.js97
7 files changed, 96 insertions, 147 deletions
diff --git a/deps/npm/node_modules/write-file-atomic/.npmignore b/deps/npm/node_modules/write-file-atomic/.npmignore
deleted file mode 100644
index 454382637b..0000000000
--- a/deps/npm/node_modules/write-file-atomic/.npmignore
+++ /dev/null
@@ -1,4 +0,0 @@
-*~
-DEADJOE
-.#*
-node_modules \ No newline at end of file
diff --git a/deps/npm/node_modules/write-file-atomic/.travis.yml b/deps/npm/node_modules/write-file-atomic/.travis.yml
deleted file mode 100644
index 3bc5d90c56..0000000000
--- a/deps/npm/node_modules/write-file-atomic/.travis.yml
+++ /dev/null
@@ -1,11 +0,0 @@
-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/deps/npm/node_modules/write-file-atomic/LICENSE b/deps/npm/node_modules/write-file-atomic/LICENSE
index af4588069d..95e65a7706 100644
--- a/deps/npm/node_modules/write-file-atomic/LICENSE
+++ b/deps/npm/node_modules/write-file-atomic/LICENSE
@@ -3,3 +3,4 @@ Copyright (c) 2015, Rebecca Turner
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
diff --git a/deps/npm/node_modules/write-file-atomic/README.md b/deps/npm/node_modules/write-file-atomic/README.md
index 26e434d194..a9d3461db1 100644
--- a/deps/npm/node_modules/write-file-atomic/README.md
+++ b/deps/npm/node_modules/write-file-atomic/README.md
@@ -19,7 +19,7 @@ callback **Function**
Atomically and asynchronously writes data to a file, replacing the file if it already
exists. data can be a string or a buffer.
-The file is initially named `filename + "." + md5hex(__filename, process.pid, ++invocations)`.
+The file is initially named `filename + "." + murmurhex(__filename, process.pid, ++invocations)`.
If writeFile completes successfully then, if passed the **chown** option it will change
the ownership of the file. Finally it renames the file back to the filename you specified. If
it encounters errors at any of these steps it will attempt to unlink the temporary file and then
diff --git a/deps/npm/node_modules/write-file-atomic/index.js b/deps/npm/node_modules/write-file-atomic/index.js
index 797e571779..519aacad98 100644
--- a/deps/npm/node_modules/write-file-atomic/index.js
+++ b/deps/npm/node_modules/write-file-atomic/index.js
@@ -2,6 +2,7 @@
var fs = require('graceful-fs')
var chain = require('slide').chain
var MurmurHash3 = require('imurmurhash')
+var extend = Object.assign || require('util')._extend
function murmurhex () {
var hash = new MurmurHash3()
@@ -20,22 +21,63 @@ module.exports = function writeFile (filename, data, options, callback) {
}
if (!options) options = {}
var tmpfile = getTmpname(filename)
- chain([
- [fs, fs.writeFile, tmpfile, data, options],
- options.chown && [fs, fs.chown, tmpfile, options.chown.uid, options.chown.gid],
- [fs, fs.rename, tmpfile, filename]
- ], function (err) {
- err ? fs.unlink(tmpfile, function () { callback(err) })
- : callback()
- })
+
+ if (options.mode && options.chmod) {
+ return thenWriteFile()
+ } else {
+ // Either mode or chown is not explicitly set
+ // Default behavior is to copy it from original file
+ return fs.stat(filename, function (err, stats) {
+ options = extend({}, options)
+ if (!err && stats && !options.mode) {
+ options.mode = stats.mode
+ }
+ if (!err && stats && !options.chown && process.getuid) {
+ options.chown = { uid: stats.uid, gid: stats.gid }
+ }
+ return thenWriteFile()
+ })
+ }
+
+ function thenWriteFile () {
+ chain([
+ [fs, fs.writeFile, tmpfile, data, options.encoding || 'utf8'],
+ options.mode && [fs, fs.chmod, tmpfile, options.mode],
+ options.chown && [fs, fs.chown, tmpfile, options.chown.uid, options.chown.gid],
+ [fs, fs.rename, tmpfile, filename]
+ ], function (err) {
+ err ? fs.unlink(tmpfile, function () { callback(err) })
+ : callback()
+ })
+ }
}
module.exports.sync = function writeFileSync (filename, data, options) {
if (!options) options = {}
var tmpfile = getTmpname(filename)
+
try {
- fs.writeFileSync(tmpfile, data, options)
+ if (!options.mode || !options.chmod) {
+ // Either mode or chown is not explicitly set
+ // Default behavior is to copy it from original file
+ try {
+ var stats = fs.statSync(filename)
+
+ options = extend({}, options)
+ if (!options.mode) {
+ options.mode = stats.mode
+ }
+ if (!options.chown && process.getuid) {
+ options.chown = { uid: stats.uid, gid: stats.gid }
+ }
+ } catch (ex) {
+ // ignore stat errors
+ }
+ }
+
+ fs.writeFileSync(tmpfile, data, options.encoding || 'utf8')
if (options.chown) fs.chownSync(tmpfile, options.chown.uid, options.chown.gid)
+ if (options.mode) fs.chmodSync(tmpfile, options.mode)
fs.renameSync(tmpfile, filename)
} catch (err) {
try { fs.unlinkSync(tmpfile) } catch (e) {}
diff --git a/deps/npm/node_modules/write-file-atomic/package.json b/deps/npm/node_modules/write-file-atomic/package.json
index 8fad457888..76e9e9bf03 100644
--- a/deps/npm/node_modules/write-file-atomic/package.json
+++ b/deps/npm/node_modules/write-file-atomic/package.json
@@ -1,40 +1,54 @@
{
"_args": [
[
- "write-file-atomic@^1.1.4",
- "/Users/ogd/Documents/projects/npm/npm"
+ {
+ "raw": "write-file-atomic@1.2.0",
+ "scope": null,
+ "escapedName": "write-file-atomic",
+ "name": "write-file-atomic",
+ "rawSpec": "1.2.0",
+ "spec": "1.2.0",
+ "type": "version"
+ },
+ "/Users/zkat/Documents/code/npm"
]
],
- "_from": "write-file-atomic@>=1.1.4 <2.0.0",
- "_id": "write-file-atomic@1.1.4",
+ "_from": "write-file-atomic@1.2.0",
+ "_id": "write-file-atomic@1.2.0",
"_inCache": true,
- "_installable": true,
"_location": "/write-file-atomic",
- "_nodeVersion": "5.1.0",
+ "_nodeVersion": "4.5.0",
+ "_npmOperationalInternal": {
+ "host": "packages-12-west.internal.npmjs.com",
+ "tmp": "tmp/write-file-atomic-1.2.0.tgz_1471552371956_0.5829780481290072"
+ },
"_npmUser": {
- "email": "ogd@aoaioxxysz.net",
- "name": "othiym23"
+ "name": "iarna",
+ "email": "me@re-becca.org"
},
- "_npmVersion": "3.5.1",
+ "_npmVersion": "3.10.7",
"_phantomChildren": {},
"_requested": {
- "name": "write-file-atomic",
- "raw": "write-file-atomic@^1.1.4",
- "rawSpec": "^1.1.4",
+ "raw": "write-file-atomic@1.2.0",
"scope": null,
- "spec": ">=1.1.4 <2.0.0",
- "type": "range"
+ "escapedName": "write-file-atomic",
+ "name": "write-file-atomic",
+ "rawSpec": "1.2.0",
+ "spec": "1.2.0",
+ "type": "version"
},
"_requiredBy": [
+ "#USER",
"/"
],
- "_shasum": "b1f52dc2e8dc0e3cb04d187a25f758a38a90ca3b",
+ "_resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-1.2.0.tgz",
+ "_shasum": "14c66d4e4cb3ca0565c28cf3b7a6f3e4d5938fab",
"_shrinkwrap": null,
- "_spec": "write-file-atomic@^1.1.4",
- "_where": "/Users/ogd/Documents/projects/npm/npm",
+ "_spec": "write-file-atomic@1.2.0",
+ "_where": "/Users/zkat/Documents/code/npm",
"author": {
- "email": "me@re-becca.org",
"name": "Rebecca Turner",
+ "email": "me@re-becca.org",
"url": "http://re-becca.org"
},
"bugs": {
@@ -49,18 +63,22 @@
"devDependencies": {
"require-inject": "^1.1.0",
"standard": "^5.4.1",
- "tap": "^2.3.1"
+ "tap": "^2.3.1",
+ "tmp": "0.0.28"
},
"directories": {},
"dist": {
- "shasum": "b1f52dc2e8dc0e3cb04d187a25f758a38a90ca3b",
- "tarball": "http://registry.npmjs.org/write-file-atomic/-/write-file-atomic-1.1.4.tgz"
+ "shasum": "14c66d4e4cb3ca0565c28cf3b7a6f3e4d5938fab",
+ "tarball": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-1.2.0.tgz"
},
- "gitHead": "42dc04a17af96ac045f4979c8c951ee5a14a8b8b",
+ "files": [
+ "index.js"
+ ],
+ "gitHead": "c29f37cb5955f597066ad7aedea7aa6f7408a5b7",
"homepage": "https://github.com/iarna/write-file-atomic",
"keywords": [
- "atomic",
- "writeFile"
+ "writeFile",
+ "atomic"
],
"license": "ISC",
"main": "index.js",
@@ -84,5 +102,5 @@
"scripts": {
"test": "standard && tap --coverage test/*.js"
},
- "version": "1.1.4"
+ "version": "1.2.0"
}
diff --git a/deps/npm/node_modules/write-file-atomic/test/basic.js b/deps/npm/node_modules/write-file-atomic/test/basic.js
deleted file mode 100644
index 13b9719733..0000000000
--- a/deps/npm/node_modules/write-file-atomic/test/basic.js
+++ /dev/null
@@ -1,97 +0,0 @@
-'use strict'
-var test = require('tap').test
-var requireInject = require('require-inject')
-var writeFileAtomic = requireInject('../index', {
- 'graceful-fs': {
- writeFile: function (tmpfile, data, options, cb) {
- if (/nowrite/.test(tmpfile)) return cb(new Error('ENOWRITE'))
- cb()
- },
- chown: function (tmpfile, uid, gid, cb) {
- if (/nochown/.test(tmpfile)) return cb(new Error('ENOCHOWN'))
- cb()
- },
- rename: function (tmpfile, filename, cb) {
- if (/norename/.test(tmpfile)) return cb(new Error('ENORENAME'))
- cb()
- },
- unlink: function (tmpfile, cb) {
- if (/nounlink/.test(tmpfile)) return cb(new Error('ENOUNLINK'))
- cb()
- },
- writeFileSync: function (tmpfile, data, options) {
- if (/nowrite/.test(tmpfile)) throw new Error('ENOWRITE')
- },
- chownSync: function (tmpfile, uid, gid) {
- if (/nochown/.test(tmpfile)) throw new Error('ENOCHOWN')
- },
- renameSync: function (tmpfile, filename) {
- if (/norename/.test(tmpfile)) throw new Error('ENORENAME')
- },
- unlinkSync: function (tmpfile) {
- if (/nounlink/.test(tmpfile)) throw new Error('ENOUNLINK')
- }
- }
-})
-var writeFileAtomicSync = writeFileAtomic.sync
-
-test('async tests', function (t) {
- t.plan(7)
- writeFileAtomic('good', 'test', {mode: '0777'}, function (err) {
- t.notOk(err, 'No errors occur when passing in options')
- })
- writeFileAtomic('good', 'test', function (err) {
- t.notOk(err, 'No errors occur when NOT passing in options')
- })
- writeFileAtomic('nowrite', 'test', function (err) {
- t.is(err.message, 'ENOWRITE', 'writeFile failures propagate')
- })
- writeFileAtomic('nochown', 'test', {chown: {uid: 100, gid: 100}}, function (err) {
- t.is(err.message, 'ENOCHOWN', 'Chown failures propagate')
- })
- writeFileAtomic('nochown', 'test', function (err) {
- t.notOk(err, 'No attempt to chown when no uid/gid passed in')
- })
- writeFileAtomic('norename', 'test', function (err) {
- t.is(err.message, 'ENORENAME', 'Rename errors propagate')
- })
- writeFileAtomic('norename nounlink', 'test', function (err) {
- t.is(err.message, 'ENORENAME', 'Failure to unlink the temp file does not clobber the original error')
- })
-})
-
-test('sync tests', function (t) {
- t.plan(7)
- var throws = function (shouldthrow, msg, todo) {
- var err
- try { todo() } catch (e) { err = e }
- t.is(shouldthrow, err.message, msg)
- }
- var noexception = function (msg, todo) {
- var err
- try { todo() } catch (e) { err = e }
- t.notOk(err, msg)
- }
-
- noexception('No errors occur when passing in options', function () {
- writeFileAtomicSync('good', 'test', {mode: '0777'})
- })
- noexception('No errors occur when NOT passing in options', function () {
- writeFileAtomicSync('good', 'test')
- })
- throws('ENOWRITE', 'writeFile failures propagate', function () {
- writeFileAtomicSync('nowrite', 'test')
- })
- throws('ENOCHOWN', 'Chown failures propagate', function () {
- writeFileAtomicSync('nochown', 'test', {chown: {uid: 100, gid: 100}})
- })
- noexception('No attempt to chown when no uid/gid passed in', function () {
- writeFileAtomicSync('nochown', 'test')
- })
- throws('ENORENAME', 'Rename errors propagate', function () {
- writeFileAtomicSync('norename', 'test')
- })
- throws('ENORENAME', 'Failure to unlink the temp file does not clobber the original error', function () {
- writeFileAtomicSync('norename nounlink', 'test')
- })
-})