From bfc9855384ef1113d1bf3dbfaa911b37a82fd300 Mon Sep 17 00:00:00 2001 From: David Pett Date: Wed, 27 Jul 2016 18:25:24 -0500 Subject: [PATCH] fix fastboot styles reloading --- lib/broccoli/fastboot-config.js | 14 +++++++++++++- package.json | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/broccoli/fastboot-config.js b/lib/broccoli/fastboot-config.js index 9f5d869a3..57e9871d2 100644 --- a/lib/broccoli/fastboot-config.js +++ b/lib/broccoli/fastboot-config.js @@ -1,6 +1,7 @@ var fs = require('fs'); var fmt = require('util').format; var uniq = require('lodash.uniq'); +var md5Hex = require('md5-hex'); var path = require('path'); var Plugin = require('broccoli-plugin'); @@ -15,6 +16,7 @@ function FastBootConfig(inputNode, options) { this.fastbootAppConfig = options.fastbootAppConfig; this.outputPaths = options.outputPaths; this.appConfig = options.appConfig; + this._fileToChecksumMap = {}; } FastBootConfig.prototype = Object.create(Plugin.prototype); @@ -31,7 +33,17 @@ FastBootConfig.prototype.build = function() { this.buildHostWhitelist(); var outputPath = path.join(this.outputPath, 'package.json'); - fs.writeFileSync(outputPath, this.toJSONString()); + this.writeFileIfContentChanged(outputPath, this.toJSONString()); +}; + +FastBootConfig.prototype.writeFileIfContentChanged = function(outputPath, content) { + var previous = this._fileToChecksumMap[outputPath]; + var next = md5Hex(content); + + if (previous !== next) { + fs.writeFileSync(outputPath, content); + this._fileToChecksumMap[outputPath] = next; // update map + } }; FastBootConfig.prototype.buildDependencies = function() { diff --git a/package.json b/package.json index 99961a915..561574b40 100644 --- a/package.json +++ b/package.json @@ -76,6 +76,7 @@ "fastboot-filter-initializers": "0.0.2", "lodash.defaults": "^4.0.1", "lodash.uniq": "^4.2.0", + "md5-hex": "^1.3.0", "portfinder": "^1.0.3", "rsvp": "^3.0.16", "silent-error": "^1.0.0"