kibana/tasks/build
2015-08-14 11:53:26 -07:00
..
archives.js [build] finish updates 2015-08-14 11:53:26 -07:00
cliIndex.js [build] stick with grunt:task naming convention 2015-08-13 21:25:40 -07:00
downloadNodes.js [build] finish updates 2015-08-14 11:53:26 -07:00
getProps.js [build] stick with grunt:task naming convention 2015-08-13 21:25:40 -07:00
index.js [build] finish updates 2015-08-14 11:53:26 -07:00
installedPlugins.js [build] stick with grunt:task naming convention 2015-08-13 21:25:40 -07:00
installNpmDeps.js [build] finish updates 2015-08-14 11:53:26 -07:00
osPackages.js [build] stick with grunt:task naming convention 2015-08-13 21:25:40 -07:00
packageJson.js [build] move some select node modules up in the tree to prevent paths over windows limit 2015-08-14 11:51:23 -07:00
pleaseManageUser.js [build] stick with grunt:task naming convention 2015-08-13 21:25:40 -07:00
pleaserun.js [build] stick with grunt:task naming convention 2015-08-13 21:25:40 -07:00
readme.js [build] stick with grunt:task naming convention 2015-08-13 21:25:40 -07:00
shasums.js [build] stick with grunt:task naming convention 2015-08-13 21:25:40 -07:00
versionedLinks.js [build] finish updates 2015-08-14 11:53:26 -07:00

let marked = require('marked');
let Promise = require('bluebird');
let { join } = require('path');
let TextRenderer = require('marked-text-renderer');
let _ = require('lodash');
let fs = require('fs');
let { AllHtmlEntities } = require('html-entities');
let entities = new AllHtmlEntities();

TextRenderer.prototype.heading = function (text, level, raw) {
  return '\n\n' + text + '\n' + _.map(text, function () { return '='; }).join('') + '\n';
};

module.exports = function (grunt) {

  grunt.registerTask('build:readme', function () {
    let transform = function (input) {
      let output = input.replace(/<\!\-\- [^\-]+ \-\->/g, '\n');
      output = marked(output);
      return entities.decode(output);
    };

    marked.setOptions({
      renderer: new TextRenderer(),
      tables: true,
      breaks: false,
      pedantic: false,
      sanitize: false,
      smartLists: true,
      smartypants: false
    });

    grunt.file.write('build/kibana/README.txt', transform(grunt.file.read('README.md')));
    grunt.file.write('build/kibana/LICENSE.txt', transform(grunt.file.read('LICENSE.md')));
  });

};