How to use the github-colors.init function in github-colors

To help you get started, we’ve selected a few github-colors examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github IonicaBizau / node-gh-polyglot / build / client.js View on Github external
// This file generates the client script
// Dependencies
var Fs = require("fs")
  , GitHubColors = require("github-colors")
  , UglifyJS = require("uglify-js")
  ;

const TEMPLATE = "(function (root) {\n"
               + "  var GitHubColors = __GITHUB_COLORS__;\n"
               + "  __GITHUB_POLYGLOT__\n"
               + "})(window);";

// Configurations
GitHubColors.init();

var ghPolyglot = Fs.readFileSync(__dirname + "/../lib/index.js", "utf-8")
  , lines = ghPolyglot.split("\n")
  , replace = {
        __GITHUB_POLYGLOT__: lines.slice(lines.indexOf("/**")).join("\n")
      , __GITHUB_COLORS__: "{ get: " + GitHubColors.get.toString() + ",\n"
                         + "colors: " + JSON.stringify(GitHubColors.colors) + "}"
    }
  , client = TEMPLATE
  ;

Object.keys(replace).forEach(function (c) {
    client = client.replace(new RegExp(c), replace[c]);
});

client = client.replace("module.exports = ", "root.GitHubPolyglot = ");

github-colors

GitHub colors and file extensions mapping

MIT
Latest version published 3 years ago

Package Health Score

45 / 100
Full package analysis