Skip to content

Commit

Permalink
fix fastboot styles reloading
Browse files Browse the repository at this point in the history
  • Loading branch information
David Pett committed Jul 27, 2016
1 parent 97d5056 commit bfc9855
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/broccoli/fastboot-config.js
Original file line number Diff line number Diff line change
@@ -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');

Expand All @@ -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);
Expand All @@ -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() {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit bfc9855

Please sign in to comment.