From 7ee062fa2ab88a735552c2761ff7c5901a842178 Mon Sep 17 00:00:00 2001 From: guybedford Date: Tue, 18 Nov 2014 14:54:51 +0200 Subject: [PATCH] dedupe overridden jspm properties --- lib/config/package.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/config/package.js b/lib/config/package.js index 66f7fb837..cc20e11e1 100644 --- a/lib/config/package.js +++ b/lib/config/package.js @@ -131,8 +131,6 @@ PackageJSON.prototype.read = function() { PackageJSON.prototype.write = function() { var pjson = this.jspmPrefix ? {} : this.originalPjson; - if (this.jspmPrefix) - this.originalPjson.jspm = pjson; var defaults = this.defaults; @@ -196,6 +194,15 @@ PackageJSON.prototype.write = function() { if (!hasProperties(pjson.buildConfig)) delete pjson.buildConfig; + // dedupe jspm properties against base properties + if (this.jspmPrefix) { + for (var p in pjson) { + if (this.originalPjson[p] === pjson[p]) + delete pjson[p]; + } + this.originalPjson.jspm = pjson; + } + // NB check that the file hasn't changed since we opened it and if so, prompt return asp(fs.writeFile)(this.fileName, JSON.stringify(this.originalPjson, null, 2) + '\n'); }