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:
authorMarcin Szczepanski <marcin@imagichine.com.au>2017-09-08 16:00:16 +0300
committerRebecca Turner <me@re-becca.org>2017-09-09 03:08:23 +0300
commit0b28ac72d29132e9b761717aba20506854465865 (patch)
tree13801478d31a5497c5e88a685aebe15adbc4b18e
parente2745004628e595b5017588aae794638568ef0fc (diff)
install: fix bug with rollback of failed optional packages on Windows
This change ensures an fsync after updating `package.json` on Windows, which prevents an issue that intermittently occurs when rolling back a package with many dependencies such as fsevents. In testing it does not appear that fsync has as much of a performance impact on Windows as it does on other platforms, so this should not affect install times on Windows materially. Fixes: #17671 Fixes: #18287 Fixes: #18453 Fixes: #18380 Fixes: #18441 PR-URL: https://github.com/npm/npm/pull/18458 Credit: @marcins Reviewed-By: @iarna
-rw-r--r--lib/install/update-package-json.js7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/install/update-package-json.js b/lib/install/update-package-json.js
index 14339d001..afffaf780 100644
--- a/lib/install/update-package-json.js
+++ b/lib/install/update-package-json.js
@@ -4,6 +4,7 @@ var writeFileAtomic = require('write-file-atomic')
var moduleName = require('../utils/module-name.js')
var deepSortObject = require('../utils/deep-sort-object.js')
var sortedObject = require('sorted-object')
+var isWindows = require('../utils/is-windows.js')
var sortKeys = [
'dependencies', 'devDependencies', 'bundleDependencies',
@@ -47,7 +48,9 @@ module.exports = function (mod, buildpath, next) {
var data = JSON.stringify(sortedObject(pkg), null, 2) + '\n'
writeFileAtomic(path.resolve(buildpath, 'package.json'), data, {
- // We really don't need this guarantee, and fsyncing here is super slow.
- fsync: false
+ // We really don't need this guarantee, and fsyncing here is super slow. Except on
+ // Windows where there isn't a big performance difference and it prevents errors when
+ // rolling back optional packages (#17671)
+ fsync: isWindows
}, next)
}