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:
authorKat Marchán <kzm@sykosomatic.org>2017-05-13 22:50:49 +0300
committerRebecca Turner <me@re-becca.org>2017-05-26 04:55:20 +0300
commit35e7996bfcb652b10c315772240953a5663f6511 (patch)
tree9fa473f4c02d6b34ef9d268a3b9e33e738e88fd3 /node_modules
parent321d7c82c532e1ad35d15907e130cab874660e54 (diff)
write-file-atomic@2.1.0
adds fsync option
Diffstat (limited to 'node_modules')
-rw-r--r--node_modules/update-notifier/node_modules/configstore/node_modules/write-file-atomic/LICENSE6
-rw-r--r--node_modules/update-notifier/node_modules/configstore/node_modules/write-file-atomic/README.md44
-rw-r--r--node_modules/update-notifier/node_modules/configstore/node_modules/write-file-atomic/index.js129
-rw-r--r--node_modules/update-notifier/node_modules/configstore/node_modules/write-file-atomic/package.json67
-rw-r--r--node_modules/write-file-atomic/README.md3
-rw-r--r--node_modules/write-file-atomic/index.js19
-rw-r--r--node_modules/write-file-atomic/package.json35
7 files changed, 277 insertions, 26 deletions
diff --git a/node_modules/update-notifier/node_modules/configstore/node_modules/write-file-atomic/LICENSE b/node_modules/update-notifier/node_modules/configstore/node_modules/write-file-atomic/LICENSE
new file mode 100644
index 000000000..95e65a770
--- /dev/null
+++ b/node_modules/update-notifier/node_modules/configstore/node_modules/write-file-atomic/LICENSE
@@ -0,0 +1,6 @@
+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/node_modules/update-notifier/node_modules/configstore/node_modules/write-file-atomic/README.md b/node_modules/update-notifier/node_modules/configstore/node_modules/write-file-atomic/README.md
new file mode 100644
index 000000000..a9d3461db
--- /dev/null
+++ b/node_modules/update-notifier/node_modules/configstore/node_modules/write-file-atomic/README.md
@@ -0,0 +1,44 @@
+write-file-atomic
+-----------------
+
+This is an extension for node's `fs.writeFile` that makes its operation
+atomic and allows you set ownership (uid/gid of the file).
+
+### var writeFileAtomic = require('write-file-atomic')<br>writeFileAtomic(filename, data, [options], callback)
+
+* filename **String**
+* data **String** | **Buffer**
+* options **Object**
+ * chown **Object**
+ * uid **Number**
+ * gid **Number**
+ * encoding **String** | **Null** default = 'utf8'
+ * mode **Number** default = 438 (aka 0666 in Octal)
+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 + "." + 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
+pass the error back to the caller.
+
+If provided, the **chown** option requires both **uid** and **gid** properties or else
+you'll get an error.
+
+The **encoding** option is ignored if **data** is a buffer. It defaults to 'utf8'.
+
+Example:
+
+```javascript
+writeFileAtomic('message.txt', 'Hello Node', {chown:{uid:100,gid:50}}, function (err) {
+ if (err) throw err;
+ console.log('It\'s saved!');
+});
+```
+
+### var writeFileAtomicSync = require('write-file-atomic').sync<br>writeFileAtomicSync(filename, data, [options])
+
+The synchronous version of **writeFileAtomic**.
diff --git a/node_modules/update-notifier/node_modules/configstore/node_modules/write-file-atomic/index.js b/node_modules/update-notifier/node_modules/configstore/node_modules/write-file-atomic/index.js
new file mode 100644
index 000000000..7bacf32ad
--- /dev/null
+++ b/node_modules/update-notifier/node_modules/configstore/node_modules/write-file-atomic/index.js
@@ -0,0 +1,129 @@
+'use strict'
+module.exports = writeFile
+module.exports.sync = writeFileSync
+module.exports._getTmpname = getTmpname // for testing
+
+var fs = require('graceful-fs')
+var chain = require('slide').chain
+var MurmurHash3 = require('imurmurhash')
+var extend = Object.assign || require('util')._extend
+
+var invocations = 0
+function getTmpname (filename) {
+ return filename + '.' +
+ MurmurHash3(__filename)
+ .hash(String(process.pid))
+ .hash(String(++invocations))
+ .result()
+}
+
+function writeFile (filename, data, options, callback) {
+ if (options instanceof Function) {
+ callback = options
+ options = null
+ }
+ if (!options) options = {}
+ fs.realpath(filename, function (_, realname) {
+ _writeFile(realname || filename, data, options, callback)
+ })
+}
+function _writeFile (filename, data, options, callback) {
+ var tmpfile = getTmpname(filename)
+
+ if (options.mode && options.chown) {
+ 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) {
+ if (err || !stats) return thenWriteFile()
+
+ options = extend({}, options)
+ if (!options.mode) {
+ options.mode = stats.mode
+ }
+ if (!options.chown && process.getuid) {
+ options.chown = { uid: stats.uid, gid: stats.gid }
+ }
+ return thenWriteFile()
+ })
+ }
+
+ function thenWriteFile () {
+ chain([
+ [writeFileAsync, tmpfile, data, options.mode, options.encoding || 'utf8'],
+ options.chown && [fs, fs.chown, tmpfile, options.chown.uid, options.chown.gid],
+ options.mode && [fs, fs.chmod, tmpfile, options.mode],
+ [fs, fs.rename, tmpfile, filename]
+ ], function (err) {
+ err ? fs.unlink(tmpfile, function () { callback(err) })
+ : callback()
+ })
+ }
+
+ // doing this instead of `fs.writeFile` in order to get the ability to
+ // call `fsync`.
+ function writeFileAsync (file, data, mode, encoding, cb) {
+ fs.open(file, 'w', options.mode, function (err, fd) {
+ if (err) return cb(err)
+ if (Buffer.isBuffer(data)) {
+ return fs.write(fd, data, 0, data.length, 0, syncAndClose)
+ } else if (data != null) {
+ return fs.write(fd, String(data), 0, String(encoding), syncAndClose)
+ } else {
+ return syncAndClose()
+ }
+ function syncAndClose (err) {
+ if (err) return cb(err)
+ fs.fsync(fd, function (err) {
+ if (err) return cb(err)
+ fs.close(fd, cb)
+ })
+ }
+ })
+ }
+}
+
+function writeFileSync (filename, data, options) {
+ if (!options) options = {}
+ try {
+ filename = fs.realpathSync(filename)
+ } catch (ex) {
+ // it's ok, it'll happen on a not yet existing file
+ }
+ var tmpfile = getTmpname(filename)
+
+ try {
+ if (!options.mode || !options.chown) {
+ // 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
+ }
+ }
+
+ var fd = fs.openSync(tmpfile, 'w', options.mode)
+ if (Buffer.isBuffer(data)) {
+ fs.writeSync(fd, data, 0, data.length, 0)
+ } else if (data != null) {
+ fs.writeSync(fd, String(data), 0, String(options.encoding || 'utf8'))
+ }
+ fs.fsyncSync(fd)
+ fs.closeSync(fd)
+ 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) {}
+ throw err
+ }
+}
diff --git a/node_modules/update-notifier/node_modules/configstore/node_modules/write-file-atomic/package.json b/node_modules/update-notifier/node_modules/configstore/node_modules/write-file-atomic/package.json
new file mode 100644
index 000000000..844452010
--- /dev/null
+++ b/node_modules/update-notifier/node_modules/configstore/node_modules/write-file-atomic/package.json
@@ -0,0 +1,67 @@
+{
+ "_from": "write-file-atomic@^1.1.2",
+ "_id": "write-file-atomic@1.3.4",
+ "_inBundle": false,
+ "_integrity": "sha1-+Aek8LHZ6ROuekgRLmzDrxmRtF8=",
+ "_location": "/update-notifier/configstore/write-file-atomic",
+ "_phantomChildren": {},
+ "_requested": {
+ "type": "range",
+ "registry": true,
+ "raw": "write-file-atomic@^1.1.2",
+ "name": "write-file-atomic",
+ "escapedName": "write-file-atomic",
+ "rawSpec": "^1.1.2",
+ "saveSpec": null,
+ "fetchSpec": "^1.1.2"
+ },
+ "_requiredBy": [
+ "/update-notifier/configstore"
+ ],
+ "_resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-1.3.4.tgz",
+ "_shasum": "f807a4f0b1d9e913ae7a48112e6cc3af1991b45f",
+ "_spec": "write-file-atomic@^1.1.2",
+ "_where": "/Users/zkat/Documents/code/npm/node_modules/update-notifier/node_modules/configstore",
+ "author": {
+ "name": "Rebecca Turner",
+ "email": "me@re-becca.org",
+ "url": "http://re-becca.org"
+ },
+ "bugs": {
+ "url": "https://github.com/iarna/write-file-atomic/issues"
+ },
+ "bundleDependencies": false,
+ "dependencies": {
+ "graceful-fs": "^4.1.11",
+ "imurmurhash": "^0.1.4",
+ "slide": "^1.1.5"
+ },
+ "deprecated": false,
+ "description": "Write files in an atomic fashion w/configurable ownership",
+ "devDependencies": {
+ "mkdirp": "^0.5.1",
+ "require-inject": "^1.4.0",
+ "rimraf": "^2.5.4",
+ "standard": "^9.0.2",
+ "tap": "^10.3.2"
+ },
+ "files": [
+ "index.js"
+ ],
+ "homepage": "https://github.com/iarna/write-file-atomic",
+ "keywords": [
+ "writeFile",
+ "atomic"
+ ],
+ "license": "ISC",
+ "main": "index.js",
+ "name": "write-file-atomic",
+ "repository": {
+ "type": "git",
+ "url": "git+ssh://git@github.com/iarna/write-file-atomic.git"
+ },
+ "scripts": {
+ "test": "standard && tap --coverage test/*.js"
+ },
+ "version": "1.3.4"
+}
diff --git a/node_modules/write-file-atomic/README.md b/node_modules/write-file-atomic/README.md
index a9d3461db..63f00420c 100644
--- a/node_modules/write-file-atomic/README.md
+++ b/node_modules/write-file-atomic/README.md
@@ -13,6 +13,7 @@ atomic and allows you set ownership (uid/gid of the file).
* uid **Number**
* gid **Number**
* encoding **String** | **Null** default = 'utf8'
+ * fsync **Boolean** default = true
* mode **Number** default = 438 (aka 0666 in Octal)
callback **Function**
@@ -30,6 +31,8 @@ you'll get an error.
The **encoding** option is ignored if **data** is a buffer. It defaults to 'utf8'.
+If the **fsync** option is **false**, writeFile will skip the final fsync call.
+
Example:
```javascript
diff --git a/node_modules/write-file-atomic/index.js b/node_modules/write-file-atomic/index.js
index 7bacf32ad..c677ee962 100644
--- a/node_modules/write-file-atomic/index.js
+++ b/node_modules/write-file-atomic/index.js
@@ -6,7 +6,6 @@ module.exports._getTmpname = getTmpname // for testing
var fs = require('graceful-fs')
var chain = require('slide').chain
var MurmurHash3 = require('imurmurhash')
-var extend = Object.assign || require('util')._extend
var invocations = 0
function getTmpname (filename) {
@@ -38,7 +37,7 @@ function _writeFile (filename, data, options, callback) {
return fs.stat(filename, function (err, stats) {
if (err || !stats) return thenWriteFile()
- options = extend({}, options)
+ options = Object.assign({}, options)
if (!options.mode) {
options.mode = stats.mode
}
@@ -75,10 +74,14 @@ function _writeFile (filename, data, options, callback) {
}
function syncAndClose (err) {
if (err) return cb(err)
- fs.fsync(fd, function (err) {
- if (err) return cb(err)
+ if (options.fsync !== false) {
+ fs.fsync(fd, function (err) {
+ if (err) return cb(err)
+ fs.close(fd, cb)
+ })
+ } else {
fs.close(fd, cb)
- })
+ }
}
})
}
@@ -99,7 +102,7 @@ function writeFileSync (filename, data, options) {
// Default behavior is to copy it from original file
try {
var stats = fs.statSync(filename)
- options = extend({}, options)
+ options = Object.assign({}, options)
if (!options.mode) {
options.mode = stats.mode
}
@@ -117,7 +120,9 @@ function writeFileSync (filename, data, options) {
} else if (data != null) {
fs.writeSync(fd, String(data), 0, String(options.encoding || 'utf8'))
}
- fs.fsyncSync(fd)
+ if (options.fsync !== false) {
+ fs.fsyncSync(fd)
+ }
fs.closeSync(fd)
if (options.chown) fs.chownSync(tmpfile, options.chown.uid, options.chown.gid)
if (options.mode) fs.chmodSync(tmpfile, options.mode)
diff --git a/node_modules/write-file-atomic/package.json b/node_modules/write-file-atomic/package.json
index a05318d86..9f8043b09 100644
--- a/node_modules/write-file-atomic/package.json
+++ b/node_modules/write-file-atomic/package.json
@@ -1,34 +1,33 @@
{
- "_from": "write-file-atomic@~1.3.3",
- "_id": "write-file-atomic@1.3.4",
- "_integrity": "sha1-+Aek8LHZ6ROuekgRLmzDrxmRtF8=",
+ "_from": "write-file-atomic@latest",
+ "_id": "write-file-atomic@2.1.0",
+ "_inBundle": false,
+ "_integrity": "sha512-0TZ20a+xcIl4u0+Mj5xDH2yOWdmQiXlKf9Hm+TgDXjTMsEYb+gDrmb8e8UNAzMCitX8NBqG4Z/FUQIyzv/R1JQ==",
"_location": "/write-file-atomic",
"_phantomChildren": {},
"_requested": {
- "type": "range",
+ "type": "tag",
"registry": true,
- "raw": "write-file-atomic@~1.3.3",
+ "raw": "write-file-atomic@latest",
"name": "write-file-atomic",
"escapedName": "write-file-atomic",
- "rawSpec": "~1.3.3",
+ "rawSpec": "latest",
"saveSpec": null,
- "fetchSpec": "~1.3.3"
+ "fetchSpec": "latest"
},
"_requiredBy": [
- "/",
- "/update-notifier/configstore"
+ "#USER",
+ "/"
],
- "_resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-1.3.4.tgz",
- "_shasum": "f807a4f0b1d9e913ae7a48112e6cc3af1991b45f",
- "_shrinkwrap": null,
- "_spec": "write-file-atomic@~1.3.3",
+ "_resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-2.1.0.tgz",
+ "_shasum": "1769f4b551eedce419f0505deae2e26763542d37",
+ "_spec": "write-file-atomic@latest",
"_where": "/Users/zkat/Documents/code/npm",
"author": {
"name": "Rebecca Turner",
"email": "me@re-becca.org",
"url": "http://re-becca.org"
},
- "bin": null,
"bugs": {
"url": "https://github.com/iarna/write-file-atomic/issues"
},
@@ -44,7 +43,7 @@
"mkdirp": "^0.5.1",
"require-inject": "^1.4.0",
"rimraf": "^2.5.4",
- "standard": "^9.0.2",
+ "standard": "^10.0.2",
"tap": "^10.3.2"
},
"files": [
@@ -58,14 +57,12 @@
"license": "ISC",
"main": "index.js",
"name": "write-file-atomic",
- "optionalDependencies": {},
- "peerDependencies": {},
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/iarna/write-file-atomic.git"
},
"scripts": {
- "test": "standard && tap --coverage test/*.js"
+ "test": "standard && tap --100 test/*.js"
},
- "version": "1.3.4"
+ "version": "2.1.0"
}