From bf60b591f093076b72e3a1bac00058b2bd450243 Mon Sep 17 00:00:00 2001 From: corime Date: Sun, 21 Oct 2018 14:09:50 +0200 Subject: [PATCH] Use native fs.writeFile in lib/install/save.js To write a file, write-file-atomic uses a temp file and replaces the original one by renaming the temp file to its original's name. In some cases this produces an EBUSY error, if the original file cannot be removed/replaced. By using fs.writeFile this issue can be avoided, since it writes the given content directly into the original file and hence does not try to replace it. Correct me if I'm wrong but I don't think there is a specific downside in using the native writeFile here. --- lib/install/save.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/install/save.js b/lib/install/save.js index 7227e78852ac7..471cb8dc07fd7 100644 --- a/lib/install/save.js +++ b/lib/install/save.js @@ -13,7 +13,6 @@ const path = require('path') const stringifyPackage = require('stringify-package') const validate = require('aproba') const without = require('lodash.without') -const writeFileAtomic = require('write-file-atomic') // if the -S|--save option is specified, then write installed packages // as dependencies to a package.json file. @@ -129,7 +128,7 @@ function savePackageJson (tree, next) { log.verbose('shrinkwrap', 'skipping write for package.json because there were no changes.') next() } else { - writeFileAtomic(saveTarget, json, next) + fs.writeFile(saveTarget, json, next) } })) }