/**
 * Copyright 2013-2015, Facebook, Inc.
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree. An additional grant
 * of patent rights can be found in the PATENTS file in the same directory.
 */

'use strict';

const crypto = require('crypto');
const fs = require('fs');

function buildCacheKey(files, base) {
  return files.reduce(
    (src, fileName) => src + fs.readFileSync(fileName),
    base
  );
}

module.exports = files => {
  const presetVersion = require('../package').dependencies['babel-preset-fbjs'];
  const cacheKey = buildCacheKey(files, presetVersion);
  return (src, file, configString) => crypto.createHash('md5')
    .update(cacheKey)
    .update(src + file + configString)
    .digest('hex');
};

@@ -708,19 +708,48 @@
 ring
-) =%3E crypto
+, options) =%3E %7B%0A    return crypto%0A      
 .cre
@@ -763,16 +763,18 @@
 ('md5')%0A
+  
     .upd
@@ -787,24 +787,26 @@
 cheKey)%0A    
+  
 .update(src 
@@ -828,16 +828,83 @@
 String)%0A
+      .update(options && options.instrument ? 'instrument' : '')%0A  
     .dig
@@ -915,11 +915,16 @@
 'hex');%0A
+  %7D;%0A
 %7D;%0A

add 'instrument' flag to createCacheKey fn