11var fs = require ( 'fs' ) ;
22var fmt = require ( 'util' ) . format ;
33var uniq = require ( 'lodash.uniq' ) ;
4+ var md5Hex = require ( 'md5-hex' ) ;
45var path = require ( 'path' ) ;
56var Plugin = require ( 'broccoli-plugin' ) ;
67
@@ -15,6 +16,7 @@ function FastBootConfig(inputNode, options) {
1516 this . fastbootAppConfig = options . fastbootAppConfig ;
1617 this . outputPaths = options . outputPaths ;
1718 this . appConfig = options . appConfig ;
19+ this . _fileToChecksumMap = { } ;
1820}
1921
2022FastBootConfig . prototype = Object . create ( Plugin . prototype ) ;
@@ -31,7 +33,17 @@ FastBootConfig.prototype.build = function() {
3133 this . buildHostWhitelist ( ) ;
3234
3335 var outputPath = path . join ( this . outputPath , 'package.json' ) ;
34- fs . writeFileSync ( outputPath , this . toJSONString ( ) ) ;
36+ this . writeFileIfContentChanged ( outputPath , this . toJSONString ( ) ) ;
37+ } ;
38+
39+ FastBootConfig . prototype . writeFileIfContentChanged = function ( outputPath , content ) {
40+ var previous = this . _fileToChecksumMap [ outputPath ] ;
41+ var next = md5Hex ( content ) ;
42+
43+ if ( previous !== next ) {
44+ fs . writeFileSync ( outputPath , content ) ;
45+ this . _fileToChecksumMap [ outputPath ] = next ; // update map
46+ }
3547} ;
3648
3749FastBootConfig . prototype . buildDependencies = function ( ) {
0 commit comments