text: // Generated by CoffeeScript 1.8.0
  (function() {
    var Template, ansi, fd, fs, isDir, mkdirp;
  
    fs = require('fs');
  
    fd = require('path');
  
    mkdirp = require('./mkdirp');
  
    ansi = require('./ansi');
  
    isDir = function(path) {
      return fs.statSync(path).isDirectory();
    };
  
    Template = (function() {
      function Template(template, path, values) {
        this.template = template;
        this.path = path;
        this.values = values != null ? values : {};
      }
  
      Template.prototype.files = function() {
        var files, next;
        if (!isDir(this.template)) {
          return [this.template];
        }
        files = [];
        next = function(dir) {
          var file, _i, _len, _ref, _results;
          _ref = fs.readdirSync(dir);
          _results = [];
          for (_i = 0, _len = _ref.length; _i < _len; _i++) {
            file = _ref[_i];
            files.push(file = "" + dir + "/" + file);
            if (isDir(file)) {
              _results.push(next(file));
            } else {
              _results.push(void 0);
            }
          }
          return _results;
        };
        next(this.template);
        return files;
      };
  
      Template.prototype.__defineGetter__('files', Template.prototype.files);
  
      Template.prototype.write = function() {
        var data, out, path, _i, _len, _ref, _results;
        mkdirp(fd.dirname(this.path));
        _ref = this.files;
        _results = [];
        for (_i = 0, _len = _ref.length; _i < _len; _i++) {
          path = _ref[_i];
          out = path.replace(this.template, '');
          out = fd.join(this.path, out);
          out = fd.normalize(out);
          if (isDir(path)) {
            fs.mkdirSync(out, 0x1fd);
            _results.push(console.log(ansi("\tcreate\t", 'green'), out));
          } else if (fs.existsSync(out)) {
            throw "" + path + " already exists";
          } else {
            data = this.parse(fs.readFileSync(path, 'utf8'));
            fs.writeFileSync(out, data);
            _results.push(console.log(ansi("\tcreate\t", 'green'), out));
          }
        }
        return _results;
      };
  
      Template.prototype.parse = function(data) {
        return data.replace(/\{\{([^}]+)\}\}/g, (function(_this) {
          return function(_, key) {
            return _this.values[key];
          };
        })(this));
      };
  
      return Template;
  
    })();
  
    module.exports = Template;
  
  }).call(this);
  