/* jshint node: true */
module.exports = {
  name: 'ember-cli-dotenv',
  config: function(env, appConfig){
    var path = require('path');
    var fs = require('fs');
    var dotenv = require('dotenv');
    var app = this.app;
    var project = this.project;
    var loadedConfig;
    var config = {};
    var hasOwn = Object.prototype.hasOwnProperty;
    if (appConfig.dotEnv && hasOwn.call(appConfig.dotEnv, 'allow')){
      console.warn("[EMBER-CLI-DOTENV] appConfig.allow has been deprecated. Please use clientAllowedKeys instead. Support will be removed in the next major version");
    }
    var allowedKeys = (appConfig.dotEnv && (appConfig.dotEnv.clientAllowedKeys || appConfig.dotEnv.allow) || []);

    var configFilePath = path.join(project.root, '.env');

    if (fs.existsSync(configFilePath)){
      // Load all server side keys
      dotenv._getKeyAndValueFromLine(configFilePath);
      dotenv._setEnvs();
      dotenv.load();
      loadedConfig = dotenv.parse(fs.readFileSync(configFilePath));
    } else  {
      loadedConfig = {};
    }

    allowedKeys.forEach(function(key){
      config[key] = loadedConfig[key];
    });

    return config;
  }
};

/* jshint node: true */
module.exports = {
  name: 'ember-cli-dotenv',
  config: function(){
    var path = require('path');
    var fs = require('fs');
    var dotenv = require('dotenv');
    var app = this.app;
    var project = this.project;
    var loadedConfig;
    var config = {};
    var hasOwn = Object.prototype.hasOwnProperty;
    if (app.options.dotEnv && hasOwn.call(app.options.dotEnv, 'allow')){
      console.warn("[EMBER-CLI-DOTENV] app.options.allow has been deprecated. Please use clientAllowedKeys instead. Support will be removed in the next major version");
    }
    var allowedKeys = (app.options.dotEnv && (app.options.dotEnv.clientAllowedKeys || app.options.dotEnv.allow) || []);

    var configFilePath = path.join(project.root, '.env');

    if (fs.existsSync(configFilePath)){
      // Load all server side keys
      dotenv._getKeyAndValueFromLine(configFilePath);
      dotenv._setEnvs();
      dotenv.load();
      loadedConfig = dotenv.parse(fs.readFileSync(configFilePath));
    } else  {
      loadedConfig = {};
    }

    allowedKeys.forEach(function(key){
      config[key] = loadedConfig[key];
    });

    return config;
  }
};

Revert "use argument passed instead of this.app"
Revert "use argument passed instead of this.app"

This reverts commit 6353e4b2acbe5be66f67de00c5bea473ce4d2a22.
