var fs   = require('fs-extra');
var path = require('path');
var mkdirp = require('mkdirp');
var util = require('util');

module.exports = {
  podsDir: '',

  description: 'Generates a style.scss file',

  beforeInstall: function (options) {
      // replace \ with / for compatibility with windows-style nested paths
      this.podsDir = this._locals(options).fileMap.__path__.replace(/\\/g, '/');
      this.podsDir = this.podsDir.replace('/' + options.entity.name, '');
      this.podsDir = this.podsDir.replace(options.entity.name, '');

      if (!options.taskOptions.pod) {
          throw new Error('You must use pods with ember-cli-sass-pods. Run with --pod.');
      }
  },

  // locals: function(options) {
  //   // Return custom template variables here.
  //   return {
  //     foo: options.entity.options.foo
  //   };
  // }

  afterInstall: function (options) {
      //console.log(util.inspect(options.project, false, null));
      var entity = options.entity;

      addScssToImportFile(entity.name, {
          name: entity.name,
          root: options.project.root,
          podsDir: this.podsDir
      });
  }
};

function addScssToImportFile (name, options) {
      var importFile = options.podsDir ? options.podsDir.replace(/(\\|\/)$/, '') : 'pods',
          filePath = path.join(options.root, 'app/styles'),
          importScssPath = path.join(filePath, importFile + '.scss'),
          podsDir = options.podsDir ? importFile + '/' : '',
          newLine = '@import "app/' + podsDir + options.name + '/style";\n',
          source;

      if (!fs.existsSync(filePath)) {
        mkdirp(filePath);
      }

      if (!fs.existsSync(importScssPath)) {
          fs.writeFileSync(importScssPath, newLine, 'utf8');
      } else {
          source = fs.readFileSync(importScssPath, 'utf-8');
          source += newLine;
          fs.writeFileSync(importScssPath, source);
      }
  }

@@ -222,32 +222,40 @@
 unction (options
+, locals
 ) %7B%0A      // rep
@@ -343,29 +343,14 @@
 r = 
-this._locals(options)
+locals
 .fil

fix locals for beforeInstall