From 98c1bc276d6d93c1d8d873dd39b6ba99d2207e00 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Sun, 7 Oct 2018 11:37:50 +0100 Subject: [PATCH] Merge project package changes to avoid overwritten changes --- .../storage/localfilesystem/projects/Project.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/red/runtime/storage/localfilesystem/projects/Project.js b/red/runtime/storage/localfilesystem/projects/Project.js index 989774d6c..f580c178e 100644 --- a/red/runtime/storage/localfilesystem/projects/Project.js +++ b/red/runtime/storage/localfilesystem/projects/Project.js @@ -358,7 +358,15 @@ Project.prototype.update = function (user, data) { promises.push(util.writeFile(this.paths['README.md'], this.description)); } if (savePackage) { - promises.push(util.writeFile(this.paths['package.json'], JSON.stringify(this.package,"",4))); + promises.push(fs.readFile(project.paths['package.json'],"utf8").then(content => { + var currentPackage = {}; + try { + currentPackage = util.parseJSON(content); + } catch(err) { + } + this.package = Object.assign(currentPackage,this.package); + return util.writeFile(this.paths['package.json'], JSON.stringify(this.package,"",4)); + })); } return when.settle(promises).then(function(res) { return {