kibana/tasks/build
2015-11-06 16:56:12 -06:00
..
archives.js [build] move to absolute paths and improve fpm/pleaserun support 2015-08-14 13:27:41 -07:00
babelOptions.js [build] babel requires the directory containing the cache exist 2015-11-04 11:10:39 -06:00
downloadNodeBuilds.js clearer task naming 2015-08-26 18:41:03 -07:00
getProps.js [build] move to absolute paths and improve fpm/pleaserun support 2015-08-14 13:27:41 -07:00
index.js Remove package.json dependencies during build 2015-09-18 14:23:24 -04:00
installedPlugins.js [build] move to absolute paths and improve fpm/pleaserun support 2015-08-14 13:27:41 -07:00
installNpmDeps.js [build] move to absolute paths and improve fpm/pleaserun support 2015-08-14 13:27:41 -07:00
osPackages.js [build] move to absolute paths and improve fpm/pleaserun support 2015-08-14 13:27:41 -07:00
packageJson.js Include node engine version in build manifests 2015-11-06 12:02:22 -05:00
pleaserun.js [build] move to absolute paths and improve fpm/pleaserun support 2015-08-14 13:27:41 -07:00
readme.js [build] move to absolute paths and improve fpm/pleaserun support 2015-08-14 13:27:41 -07:00
removePkgJsonDeps.js Remove package.json dependencies during build 2015-09-18 14:23:24 -04:00
shasums.js [build] move to absolute paths and improve fpm/pleaserun support 2015-08-14 13:27:41 -07:00
versionedLinks.js [build] allow installed plugins to use live compiled es7->es5 2015-08-14 16:20:48 -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')));
  });

};