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:
authorRebecca Turner <me@re-becca.org>2017-04-22 02:34:41 +0300
committerRebecca Turner <me@re-becca.org>2017-04-22 02:34:42 +0300
commit41c10974fe95a2e520e33e37725570c75f6126ea (patch)
treedd23667e1b9fd337c7ee547f4a33b63009edf041 /node_modules
parentf0399138e6d6f1cd7f807d523787a3b129996301 (diff)
write-file-atomic@1.3.2
Wait for `fsync` to complete before considering our file written to disk.
Diffstat (limited to 'node_modules')
-rw-r--r--node_modules/write-file-atomic/index.js24
-rw-r--r--node_modules/write-file-atomic/package.json42
2 files changed, 43 insertions, 23 deletions
diff --git a/node_modules/write-file-atomic/index.js b/node_modules/write-file-atomic/index.js
index 7939828e5..438c8e473 100644
--- a/node_modules/write-file-atomic/index.js
+++ b/node_modules/write-file-atomic/index.js
@@ -51,15 +51,30 @@ function _writeFile (filename, data, options, callback) {
function thenWriteFile () {
chain([
- [fs, fs.writeFile, tmpfile, data, options.encoding || 'utf8'],
- options.mode && [fs, fs.chmod, tmpfile, options.mode],
+ [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)
+ fs.write(fd, data, encoding, function (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) {
@@ -89,7 +104,10 @@ function writeFileSync (filename, data, options) {
}
}
- fs.writeFileSync(tmpfile, data, options.encoding || 'utf8')
+ var fd = fs.openSync(tmpfile, 'w', options.mode)
+ fs.writeSync(fd, data, 0, 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)
diff --git a/node_modules/write-file-atomic/package.json b/node_modules/write-file-atomic/package.json
index 2b1db0d60..40c29c7ae 100644
--- a/node_modules/write-file-atomic/package.json
+++ b/node_modules/write-file-atomic/package.json
@@ -2,49 +2,50 @@
"_args": [
[
{
- "raw": "write-file-atomic@1.3.1",
+ "raw": "write-file-atomic@1.3.2",
"scope": null,
"escapedName": "write-file-atomic",
"name": "write-file-atomic",
- "rawSpec": "1.3.1",
- "spec": "1.3.1",
+ "rawSpec": "1.3.2",
+ "spec": "1.3.2",
"type": "version"
},
"/Users/rebecca/code/npm"
]
],
- "_from": "write-file-atomic@1.3.1",
- "_id": "write-file-atomic@1.3.1",
+ "_from": "write-file-atomic@1.3.2",
+ "_id": "write-file-atomic@1.3.2",
"_inCache": true,
"_location": "/write-file-atomic",
- "_nodeVersion": "7.3.0",
+ "_nodeVersion": "7.7.4",
"_npmOperationalInternal": {
"host": "packages-18-east.internal.npmjs.com",
- "tmp": "tmp/write-file-atomic-1.3.1.tgz_1483776142964_0.11427561868913472"
+ "tmp": "tmp/write-file-atomic-1.3.2.tgz_1492743137041_0.5345788700506091"
},
"_npmUser": {
"name": "iarna",
"email": "me@re-becca.org"
},
- "_npmVersion": "4.1.1",
+ "_npmVersion": "4.5.0",
"_phantomChildren": {},
"_requested": {
- "raw": "write-file-atomic@1.3.1",
+ "raw": "write-file-atomic@1.3.2",
"scope": null,
"escapedName": "write-file-atomic",
"name": "write-file-atomic",
- "rawSpec": "1.3.1",
- "spec": "1.3.1",
+ "rawSpec": "1.3.2",
+ "spec": "1.3.2",
"type": "version"
},
"_requiredBy": [
"#USER",
- "/"
+ "/",
+ "/update-notifier/configstore"
],
- "_resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-1.3.1.tgz",
- "_shasum": "7d45ba32316328dd1ec7d90f60ebc0d845bb759a",
+ "_resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-1.3.2.tgz",
+ "_shasum": "f80ac5e06d3a38996ab51b5d310db57102deb902",
"_shrinkwrap": null,
- "_spec": "write-file-atomic@1.3.1",
+ "_spec": "write-file-atomic@1.3.2",
"_where": "/Users/rebecca/code/npm",
"author": {
"name": "Rebecca Turner",
@@ -69,13 +70,13 @@
},
"directories": {},
"dist": {
- "shasum": "7d45ba32316328dd1ec7d90f60ebc0d845bb759a",
- "tarball": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-1.3.1.tgz"
+ "shasum": "f80ac5e06d3a38996ab51b5d310db57102deb902",
+ "tarball": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-1.3.2.tgz"
},
"files": [
"index.js"
],
- "gitHead": "56fef5763513905d7e43aa685adad80002445474",
+ "gitHead": "d9c5f54df01043671f4ce6542cf7ebcf770e6d43",
"homepage": "https://github.com/iarna/write-file-atomic",
"keywords": [
"writeFile",
@@ -95,7 +96,8 @@
],
"name": "write-file-atomic",
"optionalDependencies": {},
- "readme": "ERROR: No README data found!",
+ "readme": "write-file-atomic\n-----------------\n\nThis is an extension for node's `fs.writeFile` that makes its operation\natomic and allows you set ownership (uid/gid of the file).\n\n### var writeFileAtomic = require('write-file-atomic')<br>writeFileAtomic(filename, data, [options], callback)\n\n* filename **String**\n* data **String** | **Buffer**\n* options **Object**\n * chown **Object**\n * uid **Number**\n * gid **Number**\n * encoding **String** | **Null** default = 'utf8'\n * mode **Number** default = 438 (aka 0666 in Octal)\ncallback **Function**\n\nAtomically and asynchronously writes data to a file, replacing the file if it already\nexists. data can be a string or a buffer.\n\nThe file is initially named `filename + \".\" + murmurhex(__filename, process.pid, ++invocations)`.\nIf writeFile completes successfully then, if passed the **chown** option it will change\nthe ownership of the file. Finally it renames the file back to the filename you specified. If\nit encounters errors at any of these steps it will attempt to unlink the temporary file and then\npass the error back to the caller.\n\nIf provided, the **chown** option requires both **uid** and **gid** properties or else\nyou'll get an error.\n\nThe **encoding** option is ignored if **data** is a buffer. It defaults to 'utf8'.\n\nExample:\n\n```javascript\nwriteFileAtomic('message.txt', 'Hello Node', {chown:{uid:100,gid:50}}, function (err) {\n if (err) throw err;\n console.log('It\\'s saved!');\n});\n```\n\n### var writeFileAtomicSync = require('write-file-atomic').sync<br>writeFileAtomicSync(filename, data, [options])\n\nThe synchronous version of **writeFileAtomic**.\n",
+ "readmeFilename": "README.md",
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/iarna/write-file-atomic.git"
@@ -103,5 +105,5 @@
"scripts": {
"test": "standard && tap --coverage test/*.js"
},
- "version": "1.3.1"
+ "version": "1.3.2"
}