<commit_before>'use strict';

var yeoman = require('yeoman-generator');
var Mustache = require('mustache');
var _s = require('underscore.string');

var LateralusComponentGenerator = yeoman.generators.Base.extend({
  initializing: function () {
    this.pkg = require('../package.json');
    this.isLateralus = this.appname === 'lateralus';

    var options = this.options || {};

    this.componentName = options.componentName || this.arguments[0];
  },

  writing: {
    app: function () {
      if (!this.componentName) {
        return;
      }

      var prefix = this.config.get('namespaceFiles') ?
        this.componentName + '-' :
        '';

      var renderData = {
        componentName: this.componentName
        ,componentClassName: _s.classify(this.componentName)
        ,prefix: prefix
      };

      var destRoot = this.isLateralus ?
          'scripts/components/' :
          'app/scripts/components/';
      this.destinationRoot(destRoot + this.componentName);

      [
        'main.js'
        ,'model.js'
        ,'view.js'
        ,'template.mustache'
        ,'styles/main.sass'
      ].forEach(function (fileName) {
        var renderedTemplate = Mustache.render(
          this.src.read(fileName), renderData);

        var targetFileName;
        if (fileName === 'main.js') {
          targetFileName = this.componentName + '.js';
        } else if (fileName === 'styles/main.sass') {
          targetFileName =
            '../../../styles/components/' + this.componentName + '.sass';
        } else {
          targetFileName = prefix + fileName;
        }
<commit_msg>Fix support for centralizing styles.<commit_after>'use strict';

var yeoman = require('yeoman-generator');
var Mustache = require('mustache');
var _s = require('underscore.string');

var LateralusComponentGenerator = yeoman.generators.Base.extend({
  initializing: function () {
    this.pkg = require('../package.json');
    this.isLateralus = this.appname === 'lateralus';

    var options = this.options || {};

    this.componentName = options.componentName || this.arguments[0];
  },

  writing: {
    app: function () {
      if (!this.componentName) {
        return;
      }

      var config = this.config.getAll();
      var namespaceFiles = config.namespaceFiles;
      var centralizeStyles = config.centralizeStyles;

      var prefix = namespaceFiles ? this.componentName + '-' : '';

      var renderData = {
        componentName: this.componentName
        ,componentClassName: _s.classify(this.componentName)
        ,prefix: prefix
      };

      var destRoot = this.isLateralus ?
          'scripts/components/' :
          'app/scripts/components/';
      this.destinationRoot(destRoot + this.componentName);

      [
        'main.js'
        ,'model.js'
        ,'view.js'
        ,'template.mustache'
        ,'styles/main.sass'
      ].forEach(function (fileName) {
        var renderedTemplate = Mustache.render(
          this.src.read(fileName), renderData);

        var targetFileName;
        if (fileName === 'main.js') {
          targetFileName = this.componentName + '.js';

        } else if (fileName === 'styles/main.sass') {

          if (centralizeStyles) {
            targetFileName =
              '../../../styles/components/' + this.componentName + '.sass';
          } else {

            targetFileName = namespaceFiles ?
              'styles/' + this.componentName + '.sass' :
              fileName;
          }
        } else {

          targetFileName = prefix + fileName;
        }

{'fraction_non_alphanumeric': 0.13728813559322034, 'fraction_numerical': 0.0005649717514124294, 'mean_word_length': 2.1958483754512637, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1995263', 'n_tokens_mistral': 1001, 'n_tokens_neox': 987, 'n_words': 190}