<commit_before>
'use strict';

var sh = require('shelljs')
  , fs = require('fs')
  , Handlebars = require('handlebars')
  , Trello = require('./trello')
  , async = require('async')
  , slug = require('slug')
  , path = require('path')
  , kramed = require('kramed');

var registerHelpers = function() {
  // We'll provide a `markdown` helper but do before registering uerland helpers
  // so they  can override use if desired
  Handlebars.registerHelper('markdown', function(markup, options) {
    return new Handlebars.SafeString(kramed(markup));
  });

  sh.ls('./src/helpers/*.js').forEach(function(f) {
    var helperName = path.basename(f, '.js')
      , helper = require(path.join(process.cwd(), f));
    Handlebars.registerHelper(helperName, helper);
  });
};

module.exports = function(opts, cb) {
  registerHelpers();
  sh.rm('-rf', 'dist');
  sh.mkdir('dist');
  fs.readFile('./src/index.hbs', function(err, data) {
    if(err) { return cb(err); }
    var cardTplSrc = data.toString()
      , cardTpl = Handlebars.compile(cardTplSrc);

    var t = new Trello(opts.trelloApiKey, opts.trelloToken);

    t.getBoardCards(opts.trelloBoardUrl, function(err, cards) {
      if(err) { return cb(err); }

      // Don't really want to force the use to install a markdow compiler...
      // just augment card data here?

      async.each(cards,
        function(card, done) {
          fs.writeFile('dist/' + slug(card.name).toLowerCase() + '.html', cardTpl(card), done)
        },
        function(err) {
          cb(err);
        });
    });
  });<commit_msg>feature: Add position to card file names<commit_after>
'use strict';

var sh = require('shelljs')
  , fs = require('fs')
  , Handlebars = require('handlebars')
  , Trello = require('./trello')
  , async = require('async')
  , slug = require('slug')
  , path = require('path')
  , kramed = require('kramed');

var registerHelpers = function() {
  // We'll provide a `markdown` helper but do before registering uerland helpers
  // so they  can override use if desired
  Handlebars.registerHelper('markdown', function(markup, options) {
    return new Handlebars.SafeString(kramed(markup));
  });

  sh.ls('./src/helpers/*.js').forEach(function(f) {
    var helperName = path.basename(f, '.js')
      , helper = require(path.join(process.cwd(), f));
    Handlebars.registerHelper(helperName, helper);
  });
};

module.exports = function(opts, cb) {
  registerHelpers();
  sh.rm('-rf', 'dist');
  sh.mkdir('dist');
  fs.readFile('./src/index.hbs', function(err, data) {
    if(err) { return cb(err); }
    var cardTplSrc = data.toString()
      , cardTpl = Handlebars.compile(cardTplSrc);

    var t = new Trello(opts.trelloApiKey, opts.trelloToken);

    t.getBoardCards(opts.trelloBoardUrl, function(err, cards) {
      if(err) { return cb(err); }

      // Don't really want to force the use to install a markdow compiler...
      // just augment card data here?

      async.each(cards,
        function(card, done) {
          fs.writeFile('dist/' + card.pos + '-' + slug(card.name).toLowerCase() + '.html', cardTpl(card), done)
        },
        function(err) {
          cb(err);
        });
    });
  });
{'fraction_non_alphanumeric': 0.16719143576826195, 'fraction_numerical': 0.0, 'mean_word_length': 3.1747700394218135, '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': '595685', 'n_tokens_mistral': 1053, 'n_tokens_neox': 1026, 'n_words': 233}