mirror of
https://github.com/mgerb/mywebsite
synced 2026-01-13 03:02:49 +00:00
Added files
This commit is contained in:
113
mongoui/mongoui-master/node_modules/highlight/bin/highlight-cli.js
generated
vendored
Executable file
113
mongoui/mongoui-master/node_modules/highlight/bin/highlight-cli.js
generated
vendored
Executable file
@@ -0,0 +1,113 @@
|
||||
#!/usr/bin/env node
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
var fs = require('fs')
|
||||
, Highlight = require('highlight')
|
||||
//, Highlight = require('../lib/highlight')
|
||||
, filename = process.argv[2]
|
||||
, langArgIndex = 4
|
||||
, langArg
|
||||
, langs
|
||||
;
|
||||
|
||||
if (filename.match(/--languages(=)?/)) {
|
||||
langArg = filename;
|
||||
langArgIndex = 3;
|
||||
filename = null;
|
||||
}
|
||||
|
||||
langArg = process.argv[langArgIndex - 1] || '';
|
||||
|
||||
if (langArg = langArg.match(/--languages(=(.*))?/)) {
|
||||
langs = (process.argv[langArgIndex]||'').split(/\s*,\s*/g);
|
||||
|
||||
if (langArg[2]) {
|
||||
langs = langArg[2].split(/,/);
|
||||
}
|
||||
}
|
||||
|
||||
function printUsage() {
|
||||
console.warn("Usages:");
|
||||
console.warn("highlight site/docs/index.html > highlighted.html");
|
||||
console.warn("cat site/docs/index.html | highlight > highlighted.html");
|
||||
}
|
||||
|
||||
function handleInput(err, text) {
|
||||
var hlBlock
|
||||
, wrappedInHtml
|
||||
;
|
||||
|
||||
if (err) {
|
||||
printUsage();
|
||||
return;
|
||||
}
|
||||
|
||||
wrappedInHtml = !!text.match(/<.*?code.*?>/i);
|
||||
|
||||
// TODO test if filename extension reveals code type
|
||||
Highlight.init(function (err) {
|
||||
if (err) {
|
||||
console.error('[highlight-cli]', err.message);
|
||||
//console.error(err.stack);
|
||||
return;
|
||||
}
|
||||
|
||||
hlBlock = Highlight.highlight(text, ' ', wrappedInHtml);
|
||||
console.info(hlBlock);
|
||||
}, langs);
|
||||
}
|
||||
|
||||
readInput(handleInput, filename);
|
||||
|
||||
//
|
||||
// this could (and probably should) be its own module
|
||||
//
|
||||
function readInput(cb, filename) {
|
||||
|
||||
function readFile() {
|
||||
fs.readFile(filename, 'utf8', function (err, text) {
|
||||
if (err) {
|
||||
console.error("[ERROR] couldn't read from '" + filename + "':");
|
||||
console.error(err.message);
|
||||
return;
|
||||
}
|
||||
|
||||
cb(err, text);
|
||||
});
|
||||
}
|
||||
|
||||
function readStdin() {
|
||||
var text = ''
|
||||
, timeoutToken
|
||||
, stdin = process.stdin
|
||||
;
|
||||
|
||||
stdin.resume();
|
||||
|
||||
// how to tell piping vs waiting for user input?
|
||||
timeoutToken = setTimeout(function () {
|
||||
cb(new Error('no stdin data'));
|
||||
stdin.pause();
|
||||
}, 1000);
|
||||
|
||||
stdin.on('data', function (chunk) {
|
||||
clearTimeout(timeoutToken);
|
||||
text += chunk;
|
||||
});
|
||||
|
||||
stdin.on('end', function () {
|
||||
cb(null, text);
|
||||
});
|
||||
}
|
||||
|
||||
if (filename) {
|
||||
readFile();
|
||||
}
|
||||
else {
|
||||
readStdin();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}());
|
||||
34
mongoui/mongoui-master/node_modules/highlight/bin/package.json
generated
vendored
Normal file
34
mongoui/mongoui-master/node_modules/highlight/bin/package.json
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"name" : "highlight-cli",
|
||||
"description" : "cli for the highlight module",
|
||||
"version" : "1.1.0",
|
||||
"author" : "AJ ONeal",
|
||||
"homepage": "https://github.com/andris9/highlight",
|
||||
"maintainers":[
|
||||
{
|
||||
"name":"andris",
|
||||
"email":"andris@node.ee"
|
||||
}
|
||||
],
|
||||
"engines": {
|
||||
"node": "*"
|
||||
},
|
||||
"repository" : {
|
||||
"type" : "git",
|
||||
"url" : "http://github.com/andris9/highlight.git"
|
||||
},
|
||||
"bin": {
|
||||
"highlight": "./highlight-cli.js"
|
||||
},
|
||||
"main": "./highlight-cli",
|
||||
"dependencies": {
|
||||
"highlight": "*"
|
||||
},
|
||||
"licenses" : [
|
||||
{
|
||||
"type": "BSD",
|
||||
"url": "http://github.com/andris9/highlight/blob/master/LICENSE"
|
||||
}
|
||||
],
|
||||
"preferGlobal": true
|
||||
}
|
||||
Reference in New Issue
Block a user