var https = require("https")
  , fs = require("fs")

  , credentialHost = process.env.npm_package_config_credentialHost

module.exports = function(cb) {
  var json = ""

  if (process.env.TRAVIS) {
    console.log("fetching remote")
    https.get({host: credentialHost}, function(res) {
      res.on("data", function(chunk){ json += chunk })
      res.on("end", parse)
    }).on("error", cb)    
  }

  else {
    console.log("fetching locale")
    fs.readFile(__dirname + "/credentials.json", "utf8", function(err, data) {
      if (err) return cb(err)

      json = data
      parse()
    })
  }

  function parse() {
    var data

    try { data = JSON.parse(json) }
    catch (err) { return cb(err) }

    data.accessKeyId && data.secretAccessKey
      ? cb(null, data)
      : cb(new Error("Invalid credentials."))
  }
}
@@ -166,71 +166,70 @@
  %22%22%0A
-%0A  if (process.env.TRAVIS) %7B%0A    console.log(%22fetching remote%22)
+    , path = %22./credentials.json%22%0A%0A  if (process.env.TRAVIS) %7B
 %0A   
@@ -358,467 +358,156 @@
 d%22, 
-parse)%0A    %7D).on(%22error%22, cb)    %0A  %7D%0A%0A  else %7B%0A    console.log(%22fetching locale%22)%0A    fs.readFile(__dirname + %22/credentials.json%22, %22utf8%22, function(err, data) %7B%0A      if (err) return cb(err)%0A%0A      json = data%0A      parse()%0A    %7D)%0A  %7D%0A%0A  function parse() %7B%0A    var data%0A%0A    try %7B data = JSON.parse(json) %7D%0A    catch (err) %7B return cb(err) %7D%0A%0A    data.accessKeyId && data.secretAccessKey%0A      ? cb(null, data)%0A      : cb(new Error(%22Invalid credentials.%22))%0A  %7D
+function() %7B%0A%0A        fs.writeFile(path, json)%0A        cb(null, require(path))%0A      %7D)%0A    %7D).on(%22error%22, cb)    %0A  %7D%0A%0A  else cb(null, require(path))
 %0A%7D

debug travis