--
This commit is contained in:
parent
24f3d27984
commit
6b60015c02
9588 changed files with 1149251 additions and 49 deletions
1
node_modules/cardinal/.npmignore
generated
vendored
Normal file
1
node_modules/cardinal/.npmignore
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
assets
|
||||
5
node_modules/cardinal/.travis.yml
generated
vendored
Normal file
5
node_modules/cardinal/.travis.yml
generated
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
language: node_js
|
||||
node_js:
|
||||
- "0.10"
|
||||
- "0.12"
|
||||
- "iojs"
|
||||
23
node_modules/cardinal/LICENSE
generated
vendored
Normal file
23
node_modules/cardinal/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
Copyright 2012 Thorsten Lorenz.
|
||||
All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation
|
||||
files (the "Software"), to deal in the Software without
|
||||
restriction, including without limitation the rights to use,
|
||||
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
127
node_modules/cardinal/README.md
generated
vendored
Normal file
127
node_modules/cardinal/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
# cardinal [](http://travis-ci.org/thlorenz/cardinal)
|
||||
|
||||
[](https://nodei.co/npm/cardinal/)
|
||||
|
||||
**car·di·nal** *(kärdn-l, kärdnl)* - crested thick-billed North American finch having bright red plumage in the male.
|
||||
|
||||

|
||||
|
||||
## Features
|
||||
|
||||
- highlights JavaScript code with ANSI colors to improve terminal output
|
||||
- theming support, see [custom color themes](https://github.com/thlorenz/cardinal/tree/master/themes)
|
||||
- optionally print line numbers
|
||||
- API and command line interface (`cdl`)
|
||||
- `.cardinalrc` config to customize settings
|
||||
- supports UNIX pipes
|
||||
|
||||
***
|
||||
|
||||
**Table of Contents** *generated with [DocToc](http://doctoc.herokuapp.com/)*
|
||||
|
||||
- [Installation](#installation)
|
||||
- [As library](#as-library)
|
||||
- [As Commandline Tool](#as-commandline-tool)
|
||||
- [Commandline](#commandline)
|
||||
- [Highlight a file](#highlight-a-file)
|
||||
- [As part of a UNIX pipe](#as-part-of-a-unix-pipe)
|
||||
- [Theme](#theme)
|
||||
- [API](#api)
|
||||
- [*highlight(code[, opts])*](#highlightcode-opts)
|
||||
- [*highlightFileSync(fullPath[, opts])*](#highlightfilesyncfullpath-opts)
|
||||
- [*highlightFile(fullPath[, opts], callback)*](#highlightfilefullpath-opts-callback)
|
||||
- [opts](#opts)
|
||||
- [Examples ([*browse*](https://github.com/thlorenz/cardinal/tree/master/examples))](#examples-[browse]https://githubcom/thlorenz/cardinal/tree/master/examples)
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
### As library
|
||||
|
||||
npm install cardinal
|
||||
|
||||
### As Commandline Tool
|
||||
|
||||
[sudo] npm install -g cardinal
|
||||
|
||||
**Note:**
|
||||
|
||||
When installed globally, cardinal exposes itself as the `cdl` command.
|
||||
|
||||
## Commandline
|
||||
|
||||
### Highlight a file
|
||||
|
||||
cdl <file.js> [options]
|
||||
|
||||
**options**:
|
||||
- `--nonum`: turns off line number printing (relevant if it is turned on inside `~/.cardinalrc`
|
||||
|
||||
### As part of a UNIX pipe
|
||||
|
||||
cat file.js | grep console | cdl
|
||||
|
||||
**Note:**
|
||||
|
||||
Not all code lines may be parsable JavaScript. In these cases the line is printed to the terminal without
|
||||
highlighting it.
|
||||
|
||||
### Theme
|
||||
|
||||
The default theme will be used for highlighting.
|
||||
|
||||
To use a different theme, include a `.cardinalrc` file in your `HOME` directory.
|
||||
|
||||
This is a JSON file of the following form:
|
||||
|
||||
```json
|
||||
{
|
||||
"theme": "hide-semicolons",
|
||||
"linenos": true|false
|
||||
}
|
||||
```
|
||||
|
||||
- `theme` can be the name of any of the [built-in themes](https://github.com/thlorenz/cardinal/tree/master/themes) or the
|
||||
full path to a custom theme anywhere on your computer.
|
||||
- linenos toggles line number printing
|
||||
|
||||
## API
|
||||
|
||||
### *highlight(code[, opts])*
|
||||
|
||||
- returns the highlighted version of the passed code ({String}) or throws an error if it was not able to parse it
|
||||
- opts (see below)
|
||||
|
||||
### *highlightFileSync(fullPath[, opts])*
|
||||
|
||||
- returns the highlighted version of the file whose fullPath ({String}) was passed or throws an error if it was not able
|
||||
to parse it
|
||||
- opts (see below)
|
||||
|
||||
### *highlightFile(fullPath[, opts], callback)*
|
||||
|
||||
- calls back with the highlighted version of the file whose fullPath ({String}) was passed or with an error if it was not able
|
||||
to parse it
|
||||
- opts (see below)
|
||||
- `callback` ({Function}) has the following signature: `function (err, highlighted) { .. }`
|
||||
|
||||
### opts
|
||||
|
||||
opts is an {Object} with the following properties:
|
||||
|
||||
- `theme` {Object} is used to optionally override the theme used to highlight
|
||||
- `linenos` {Boolean} if `true` line numbers are included in the highlighted code
|
||||
- `firstline` {Integer} sets line number of the first line when line numbers are printed
|
||||
|
||||
**Note** The `json` option is obsoleted and not necessary anymore as cardinal properly understands both JSON and JavaScript.
|
||||
|
||||
## Examples ([*browse*](https://github.com/thlorenz/cardinal/tree/master/examples))
|
||||
|
||||
- [sample .cardinalrc](https://github.com/thlorenz/cardinal/blob/master/examples/.cardinalrc)
|
||||
- [highlighting a code snippet](https://github.com/thlorenz/cardinal/blob/master/examples/highlight-string.js) via
|
||||
***highlight()***
|
||||
- [file that highlights itself](https://github.com/thlorenz/cardinal/blob/master/examples/highlight-self.js) via
|
||||
***highlightFile()*** including line numbers
|
||||
- [file that highlights itself hiding all
|
||||
semicolons](https://github.com/thlorenz/cardinal/blob/master/examples/highlight-self-hide-semicolons.js) via
|
||||
***highlightFileSync()***
|
||||
74
node_modules/cardinal/bin/cdl.js
generated
vendored
Executable file
74
node_modules/cardinal/bin/cdl.js
generated
vendored
Executable file
|
|
@ -0,0 +1,74 @@
|
|||
#!/usr/bin/env node
|
||||
var cardinal = require('..')
|
||||
, utl = require('../utl')
|
||||
, settings = require('../settings')
|
||||
, args = process.argv
|
||||
, theme = settings.resolveTheme()
|
||||
, opts = settings.getSettings()
|
||||
, highlighted
|
||||
;
|
||||
|
||||
opts = opts || {};
|
||||
opts.theme = theme;
|
||||
|
||||
function usage() {
|
||||
var msg = [
|
||||
'Usage: cdl <filename.js> [options]'
|
||||
, ''
|
||||
, 'Options (~/.cardinalrc overrides):'
|
||||
, ' --nonum: turn off line printing'
|
||||
, ''
|
||||
, 'Unix Pipe Example: cat filename.js | grep console | cdl'
|
||||
, ''
|
||||
].join('\n');
|
||||
console.log(msg);
|
||||
}
|
||||
|
||||
function highlightFile () {
|
||||
try {
|
||||
highlighted = cardinal.highlightFileSync(args[2], opts);
|
||||
console.log(highlighted);
|
||||
} catch (e) {
|
||||
console.trace();
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
// E.g., "cardinal myfile.js"
|
||||
if (args.length === 3) return highlightFile();
|
||||
|
||||
var opt = args[3];
|
||||
|
||||
// E.g., "cardinal myfile.js --nonum"
|
||||
if (opt && opt.indexOf('--') === 0 ) {
|
||||
if ((/^--(nonum|noline)/i).test(opt)) opts.linenos = false;
|
||||
else {
|
||||
usage();
|
||||
return console.error('Unknown option: ', opt);
|
||||
}
|
||||
|
||||
return highlightFile();
|
||||
}
|
||||
|
||||
|
||||
// UNIX pipes e.g., "cat myfile.js | grep console | cardinal
|
||||
var stdin = process.stdin
|
||||
, stdout = process.stdout;
|
||||
|
||||
// line numbers don't make sense when we are printing line by line
|
||||
opts.linenos = false;
|
||||
|
||||
stdin.setEncoding('utf-8');
|
||||
stdin.resume();
|
||||
stdin
|
||||
.on('data', function (chunk) {
|
||||
chunk.split('\n').forEach(function (line) {
|
||||
try {
|
||||
stdout.write(cardinal.highlight(line, opts) + '\n');
|
||||
} catch (e) {
|
||||
// line doesn't represent a valid js snippet and therefore cannot be parsed -> just print as is
|
||||
stdout.write(line + '\n');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
5
node_modules/cardinal/cardinal.js
generated
vendored
Normal file
5
node_modules/cardinal/cardinal.js
generated
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
module.exports = {
|
||||
highlight: require('./lib/highlight')
|
||||
, highlightFile: require('./lib/highlightFile')
|
||||
, highlightFileSync: require('./lib/highlightFileSync')
|
||||
};
|
||||
3
node_modules/cardinal/examples/.cardinalrc
generated
vendored
Normal file
3
node_modules/cardinal/examples/.cardinalrc
generated
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"theme": "hide-semicolons"
|
||||
}
|
||||
7
node_modules/cardinal/examples/README.md
generated
vendored
Normal file
7
node_modules/cardinal/examples/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
# Cardinal Examples
|
||||
|
||||
You can run the examples individually or as a demo:
|
||||
|
||||
- install cardinal: `npm install cardinal`
|
||||
- explore cardinal: `npm explore cardinal`
|
||||
- run the demo: `npm run demo`
|
||||
10
node_modules/cardinal/examples/highlight-json.js
generated
vendored
Normal file
10
node_modules/cardinal/examples/highlight-json.js
generated
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
// This file will highlight the passed code using the custom theme when run via: "node highlight-json"
|
||||
|
||||
var cardinal = require('..');
|
||||
|
||||
var json = JSON.stringify({
|
||||
foo: 'bar',
|
||||
baz: 'quux'
|
||||
});
|
||||
|
||||
console.log(cardinal.highlight(json));
|
||||
22
node_modules/cardinal/examples/highlight-self-hide-semicolons.js
generated
vendored
Normal file
22
node_modules/cardinal/examples/highlight-self-hide-semicolons.js
generated
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* This file will highlight itself using a custom theme when run via: "node highlight-self-hide-semicolons"
|
||||
* The custom theme highlights semicolons as 'black', thus hiding them.
|
||||
*/
|
||||
|
||||
var cardinal = require('..')
|
||||
, hideSemicolonsTheme = require('../themes/hide-semicolons');
|
||||
|
||||
function highlight () {
|
||||
|
||||
// Using the synchronous highlightFileSync()
|
||||
// For asynchronous highlighting use: highlightFile() - see highlight-self.js
|
||||
|
||||
try {
|
||||
var highlighted = cardinal.highlightFileSync(__filename, {theme: hideSemicolonsTheme});
|
||||
console.log(highlighted);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
}
|
||||
|
||||
highlight();
|
||||
16
node_modules/cardinal/examples/highlight-self.js
generated
vendored
Normal file
16
node_modules/cardinal/examples/highlight-self.js
generated
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
// This file will highlight itself using the default theme when run via: "node highlight-self"
|
||||
|
||||
var cardinal = require('..');
|
||||
|
||||
function highlight () {
|
||||
|
||||
// Using the asynchronous highlightFile()
|
||||
// For synchronous highlighting use: highlightFileSync() - see highlight-self-hide-semicolons.js
|
||||
|
||||
cardinal.highlightFile(__filename, { linenos: true }, function (err, res) {
|
||||
if (err) return console.error(err);
|
||||
console.log(res);
|
||||
});
|
||||
}
|
||||
|
||||
highlight();
|
||||
14
node_modules/cardinal/examples/highlight-string.js
generated
vendored
Normal file
14
node_modules/cardinal/examples/highlight-string.js
generated
vendored
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
// This file will highlight the passed code using the custom theme when run via: "node highlight-string"
|
||||
|
||||
var cardinal = require('..');
|
||||
|
||||
var code = '' +
|
||||
|
||||
function add (a, b) {
|
||||
var sum = a + b;
|
||||
return sum;
|
||||
} +
|
||||
|
||||
'';
|
||||
|
||||
console.log(cardinal.highlight(code));
|
||||
76
node_modules/cardinal/lib/highlight.js
generated
vendored
Normal file
76
node_modules/cardinal/lib/highlight.js
generated
vendored
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
var redeyed = require('redeyed')
|
||||
, theme = require('../themes/default')
|
||||
, colors = require('ansicolors')
|
||||
|
||||
, colorSurround = colors.brightBlack
|
||||
, surroundClose = '\u001b[39m'
|
||||
;
|
||||
|
||||
function trimEmptyLines(lines) {
|
||||
|
||||
// remove lines from the end until we find a non-empy one
|
||||
var line = lines.pop();
|
||||
while(!line || !line.length)
|
||||
line = lines.pop();
|
||||
|
||||
// put the non-empty line back
|
||||
if (line) lines.push(line);
|
||||
}
|
||||
|
||||
function addLinenos (highlightedCode, firstline) {
|
||||
var highlightedLines = highlightedCode.split('\n');
|
||||
|
||||
trimEmptyLines(highlightedLines);
|
||||
|
||||
var linesLen = highlightedLines.length
|
||||
, lines = []
|
||||
, totalDigits
|
||||
, lineno
|
||||
;
|
||||
|
||||
function getDigits (n) {
|
||||
if (n < 10) return 1;
|
||||
if (n < 100) return 2;
|
||||
if (n < 1000) return 3;
|
||||
if (n < 10000) return 4;
|
||||
// this works for up to 99,999 lines - any questions?
|
||||
return 5;
|
||||
}
|
||||
|
||||
function pad (n, totalDigits) {
|
||||
// not pretty, but simple and should perform quite well
|
||||
var padDigits= totalDigits - getDigits(n);
|
||||
switch(padDigits) {
|
||||
case 0: return '' + n;
|
||||
case 1: return ' ' + n;
|
||||
case 2: return ' ' + n;
|
||||
case 3: return ' ' + n;
|
||||
case 4: return ' ' + n;
|
||||
case 5: return ' ' + n;
|
||||
}
|
||||
}
|
||||
|
||||
totalDigits = getDigits(linesLen + firstline - 1);
|
||||
|
||||
for (var i = 0; i < linesLen; i++) {
|
||||
// Don't close the escape sequence here in order to not break multi line code highlights like block comments
|
||||
lineno = colorSurround(pad(i + firstline, totalDigits) + ': ').replace(surroundClose, '');
|
||||
lines.push(lineno + highlightedLines[i]);
|
||||
}
|
||||
|
||||
return lines.join('\n');
|
||||
}
|
||||
|
||||
module.exports = function highlight (code, opts) {
|
||||
opts = opts || { };
|
||||
try {
|
||||
|
||||
var result = redeyed(code, opts.theme || theme)
|
||||
, firstline = opts.firstline && !isNaN(opts.firstline) ? opts.firstline : 1;
|
||||
|
||||
return opts.linenos ? addLinenos(result.code, firstline) : result.code;
|
||||
} catch (e) {
|
||||
e.message = 'Unable to perform highlight. The code contained syntax errors: ' + e.message;
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
23
node_modules/cardinal/lib/highlightFile.js
generated
vendored
Normal file
23
node_modules/cardinal/lib/highlightFile.js
generated
vendored
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
var fs = require('fs')
|
||||
, highlight = require('./highlight');
|
||||
|
||||
function isFunction (obj) {
|
||||
return toString.call(obj) == '[object Function]';
|
||||
}
|
||||
|
||||
module.exports = function highlightFile (fullPath, opts, cb) {
|
||||
if (isFunction(opts)) {
|
||||
cb = opts;
|
||||
opts = { };
|
||||
}
|
||||
opts = opts || { };
|
||||
|
||||
fs.readFile(fullPath, 'utf-8', function (err, code) {
|
||||
if (err) return cb(err);
|
||||
try {
|
||||
cb(null, highlight(code, opts));
|
||||
} catch (e) {
|
||||
cb(e);
|
||||
}
|
||||
});
|
||||
};
|
||||
8
node_modules/cardinal/lib/highlightFileSync.js
generated
vendored
Normal file
8
node_modules/cardinal/lib/highlightFileSync.js
generated
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
var fs = require('fs')
|
||||
, highlight = require('./highlight');
|
||||
|
||||
module.exports = function highlightFileSync (fullPath, opts) {
|
||||
var code = fs.readFileSync(fullPath, 'utf-8');
|
||||
opts = opts || { };
|
||||
return highlight(code, opts);
|
||||
};
|
||||
106
node_modules/cardinal/package.json
generated
vendored
Normal file
106
node_modules/cardinal/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
{
|
||||
"_args": [
|
||||
[
|
||||
{
|
||||
"raw": "cardinal@^1.0.0",
|
||||
"scope": null,
|
||||
"escapedName": "cardinal",
|
||||
"name": "cardinal",
|
||||
"rawSpec": "^1.0.0",
|
||||
"spec": ">=1.0.0 <2.0.0",
|
||||
"type": "range"
|
||||
},
|
||||
"/Users/jose/Documents/GitHub/Mods/node_modules/marked-terminal"
|
||||
]
|
||||
],
|
||||
"_from": "cardinal@>=1.0.0 <2.0.0",
|
||||
"_id": "cardinal@1.0.0",
|
||||
"_inCache": true,
|
||||
"_location": "/cardinal",
|
||||
"_nodeVersion": "4.4.6",
|
||||
"_npmOperationalInternal": {
|
||||
"host": "packages-12-west.internal.npmjs.com",
|
||||
"tmp": "tmp/cardinal-1.0.0.tgz_1472599040783_0.3466065616812557"
|
||||
},
|
||||
"_npmUser": {
|
||||
"name": "thlorenz",
|
||||
"email": "thlorenz@gmx.de"
|
||||
},
|
||||
"_npmVersion": "2.15.6",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"raw": "cardinal@^1.0.0",
|
||||
"scope": null,
|
||||
"escapedName": "cardinal",
|
||||
"name": "cardinal",
|
||||
"rawSpec": "^1.0.0",
|
||||
"spec": ">=1.0.0 <2.0.0",
|
||||
"type": "range"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/marked-terminal"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/cardinal/-/cardinal-1.0.0.tgz",
|
||||
"_shasum": "50e21c1b0aa37729f9377def196b5a9cec932ee9",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "cardinal@^1.0.0",
|
||||
"_where": "/Users/jose/Documents/GitHub/Mods/node_modules/marked-terminal",
|
||||
"author": {
|
||||
"name": "Thorsten Lorenz",
|
||||
"email": "thlorenz@gmx.de",
|
||||
"url": "thlorenz.com"
|
||||
},
|
||||
"bin": {
|
||||
"cdl": "./bin/cdl.js"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/thlorenz/cardinal/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"ansicolors": "~0.2.1",
|
||||
"redeyed": "~1.0.0"
|
||||
},
|
||||
"description": "Syntax highlights JavaScript code with ANSI colors to be printed to the terminal.",
|
||||
"devDependencies": {
|
||||
"readdirp": "~0.2.1",
|
||||
"tap": "~0.3.1"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "50e21c1b0aa37729f9377def196b5a9cec932ee9",
|
||||
"tarball": "https://registry.npmjs.org/cardinal/-/cardinal-1.0.0.tgz"
|
||||
},
|
||||
"gitHead": "ce0befef82535d86218fc32e5872809212e4b274",
|
||||
"homepage": "https://github.com/thlorenz/cardinal#readme",
|
||||
"keywords": [
|
||||
"syntax",
|
||||
"highlight",
|
||||
"theme",
|
||||
"javascript",
|
||||
"json",
|
||||
"terminal",
|
||||
"console",
|
||||
"print",
|
||||
"output"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "cardinal.js",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "thlorenz",
|
||||
"email": "thlorenz@gmx.de"
|
||||
}
|
||||
],
|
||||
"name": "cardinal",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/thlorenz/cardinal.git"
|
||||
},
|
||||
"scripts": {
|
||||
"demo": "node examples/highlight-string.js; node examples/highlight-self; node examples/highlight-self-hide-semicolons;",
|
||||
"test": "tap ./test/*.js"
|
||||
},
|
||||
"version": "1.0.0"
|
||||
}
|
||||
51
node_modules/cardinal/settings.js
generated
vendored
Normal file
51
node_modules/cardinal/settings.js
generated
vendored
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
var path = require('path')
|
||||
, util = require('util')
|
||||
, fs = require('fs')
|
||||
, utl = require('./utl')
|
||||
, home = process.env.HOME
|
||||
, settings;
|
||||
|
||||
function getSettings (home_) {
|
||||
if (settings) return settings;
|
||||
try {
|
||||
settingsJson = fs.readFileSync(path.join(home_ || home, '.cardinalrc'), 'utf-8');
|
||||
} catch (_) {
|
||||
// no .cardinalrc found - not a problem
|
||||
return undefined;
|
||||
}
|
||||
try {
|
||||
return JSON.parse(settingsJson);
|
||||
} catch (e) {
|
||||
// Have a .cardinalrc, but something about it is wrong - warn the user
|
||||
// Coudn't parse the contained JSON
|
||||
console.error(e);
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
// home_ mainly to be used during tests
|
||||
// Resolves the preferred theme from the .cardinalrc found in the HOME directory
|
||||
// If it couldn't be resolved, undefined is returned
|
||||
function resolveTheme (home_) {
|
||||
var themePath
|
||||
, settings = getSettings(home_);
|
||||
|
||||
if (!settings || !settings.theme) return undefined;
|
||||
|
||||
try {
|
||||
// allow specifying just the name of a built-in theme or a full path to a custom theme
|
||||
themePath = utl.isPath(settings.theme) ? settings.theme : path.join(__dirname, 'themes', settings.theme);
|
||||
|
||||
return require(themePath);
|
||||
} catch (e) {
|
||||
// Specified theme path is invalid
|
||||
console.error(e);
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
resolveTheme: resolveTheme
|
||||
, getSettings: getSettings
|
||||
};
|
||||
|
||||
25
node_modules/cardinal/test/cardinal-highlight-block-comment.js
generated
vendored
Normal file
25
node_modules/cardinal/test/cardinal-highlight-block-comment.js
generated
vendored
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
'use strict';
|
||||
/*jshint asi: true*/
|
||||
|
||||
var test = require('tap').test
|
||||
, fs = require('fs')
|
||||
, customTheme = require('./fixtures/custom')
|
||||
, cardinal = require('..')
|
||||
|
||||
function inspect(obj, depth) {
|
||||
console.log(require('util').inspect(obj, false, depth || 5, true));
|
||||
}
|
||||
|
||||
test('\nhighlighting a block comment without line numbers', function (t) {
|
||||
var code = fs.readFileSync(__dirname + '/fixtures/block-comment.js', 'utf8');
|
||||
var highlighted = cardinal.highlight(code, { theme: customTheme });
|
||||
t.equal(highlighted, '\n\u001b[90m/**\n * This is a meaningless block jsdoc for a meaningless function.\n * Joins two strings, separating them to appear on two lines.\n * \n * @name foo\n * @function\n * @param uno {String} first string\n * @param dos {String} second string\n * @return {String} result of the join\n */\u001b[39m\n\u001b[96mmodule\u001b[39m\u001b[32m.\u001b[39m\u001b[96mexports\u001b[39m \u001b[93m=\u001b[39m \u001b[94mfunction\u001b[39m \u001b[96mfoo\u001b[39m \u001b[90m(\u001b[39m\u001b[96muno\u001b[39m\u001b[32m,\u001b[39m \u001b[96mdos\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m\n \u001b[31mreturn\u001b[39m \u001b[96muno\u001b[39m \u001b[93m+\u001b[39m \u001b[92m\'\\n\'\u001b[39m \u001b[93m+\u001b[39m \u001b[96mdos\u001b[39m\u001b[90m;\u001b[39m\n\u001b[33m}\u001b[39m\n')
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('\nhighlighting a block comment with line numbers', function (t) {
|
||||
var code = fs.readFileSync(__dirname + '/fixtures/block-comment.js', 'utf8');
|
||||
var highlighted = cardinal.highlight(code, { theme: customTheme, linenos: true });
|
||||
t.equal(highlighted, '\u001b[90m 1: \n\u001b[90m 2: \u001b[90m/**\n\u001b[90m 3: * This is a meaningless block jsdoc for a meaningless function.\n\u001b[90m 4: * Joins two strings, separating them to appear on two lines.\n\u001b[90m 5: * \n\u001b[90m 6: * @name foo\n\u001b[90m 7: * @function\n\u001b[90m 8: * @param uno {String} first string\n\u001b[90m 9: * @param dos {String} second string\n\u001b[90m10: * @return {String} result of the join\n\u001b[90m11: */\u001b[39m\n\u001b[90m12: \u001b[96mmodule\u001b[39m\u001b[32m.\u001b[39m\u001b[96mexports\u001b[39m \u001b[93m=\u001b[39m \u001b[94mfunction\u001b[39m \u001b[96mfoo\u001b[39m \u001b[90m(\u001b[39m\u001b[96muno\u001b[39m\u001b[32m,\u001b[39m \u001b[96mdos\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m\n\u001b[90m13: \u001b[31mreturn\u001b[39m \u001b[96muno\u001b[39m \u001b[93m+\u001b[39m \u001b[92m\'\\n\'\u001b[39m \u001b[93m+\u001b[39m \u001b[96mdos\u001b[39m\u001b[90m;\u001b[39m\n\u001b[90m14: \u001b[33m}\u001b[39m')
|
||||
t.end()
|
||||
})
|
||||
95
node_modules/cardinal/test/cardinal-highlight-diff-spike.js
generated
vendored
Normal file
95
node_modules/cardinal/test/cardinal-highlight-diff-spike.js
generated
vendored
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
/*jshint asi:true */
|
||||
'use strict';
|
||||
|
||||
var fs = require('fs')
|
||||
, path = require('path')
|
||||
, utl = require('../utl')
|
||||
, highlighter = require('..')
|
||||
, colors = require('ansicolors')
|
||||
, diffFile = path.join(__dirname, 'fixtures', 'git-diff.txt')
|
||||
, diff = fs.readFileSync(diffFile, 'utf-8')
|
||||
|
||||
|
||||
// @@ is not a valid js token, so when we see it, we can be sure that we are dealing with a git or svn diff
|
||||
var diffRegex = /^@@[^@]+@@$/m;
|
||||
var diffIndRegex = /^(@@[^@]+@@)(.*)$/;
|
||||
var addRemRegex = /^[+\-]/;
|
||||
var lines = diff.split('\n');
|
||||
|
||||
function isDiff(lines) {
|
||||
return !!lines
|
||||
.filter(function (line) {
|
||||
return diffRegex.test(line);
|
||||
})
|
||||
.length;
|
||||
}
|
||||
|
||||
var diff = isDiff(lines);
|
||||
|
||||
function tryHighlight(code) {
|
||||
|
||||
// TODO: need to remove symbols added to get valid code
|
||||
// this should be done by getting the splits instead of the actual code from the highlighter
|
||||
// now we can remove first / last one after highlighting completed
|
||||
function tryAppending(appended, tryNext) {
|
||||
try {
|
||||
return highlighter.highlight(code + appended);
|
||||
} catch (e) {
|
||||
return tryNext(code);
|
||||
}
|
||||
}
|
||||
|
||||
function tryRemoveLeadingComma(tryNext) {
|
||||
var success;
|
||||
try {
|
||||
success = highlighter.highlight(code.replace(/^( +),(.+)$/, '$1 $2'));
|
||||
return success;
|
||||
} catch (e) {
|
||||
return tryNext(code);
|
||||
}
|
||||
}
|
||||
|
||||
function tryPlain() {
|
||||
try {
|
||||
return highlighter.highlight(code);
|
||||
} catch (e) {
|
||||
return tryCloseMustache();
|
||||
}
|
||||
}
|
||||
|
||||
function tryCloseMustache() { return tryAppending('}', tryCloseParen); }
|
||||
|
||||
function tryCloseParen() { return tryAppending('\\)', tryCloseMustacheParen); }
|
||||
|
||||
function tryCloseMustacheParen() { return tryAppending('})', tryRemovingCommas);}
|
||||
|
||||
function tryRemovingCommas() { return tryRemoveLeadingComma(giveUp); }
|
||||
|
||||
function giveUp() { return code; }
|
||||
|
||||
return tryPlain();
|
||||
}
|
||||
|
||||
function highlightDiffInd(line, matches) {
|
||||
var highlighted = colors.brightBlue(matches[1])
|
||||
, code = matches[2];
|
||||
return code ? highlighted + tryHighlight(code) : highlighted;
|
||||
}
|
||||
|
||||
function colorsAddRemove(c) {
|
||||
return addRemRegex.test(c) ? colors.yellow(c) : c;
|
||||
}
|
||||
|
||||
function highlightDiff(line) {
|
||||
var diffIndMatches = diffIndRegex.exec(line);
|
||||
|
||||
return diffIndMatches
|
||||
? highlightDiffInd(line, diffIndMatches)
|
||||
: colorsAddRemove(line[0]) + tryHighlight(line.slice(1));
|
||||
}
|
||||
|
||||
var highlightFn = diff ? highlightDiff : tryHighlight;
|
||||
var highlightedLines = lines.map(highlightFn);
|
||||
|
||||
console.log(highlightedLines.join('\n'));
|
||||
|
||||
50
node_modules/cardinal/test/cardinal-highlight-file-async.js
generated
vendored
Normal file
50
node_modules/cardinal/test/cardinal-highlight-file-async.js
generated
vendored
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
'use strict';
|
||||
/*jshint asi: true*/
|
||||
|
||||
var test = require('tap').test
|
||||
, util = require('util')
|
||||
, fs = require('fs')
|
||||
, path = require('path')
|
||||
, customTheme = require('./fixtures/custom')
|
||||
, cardinal = require('..')
|
||||
|
||||
function inspect (obj) {
|
||||
return console.log(util.inspect(obj, false, 5, false))
|
||||
}
|
||||
|
||||
var file = path.join(__dirname, 'fixtures/foo.js')
|
||||
, fileWithErrors = path.join(__dirname, 'fixtures/foo-with-errors.js')
|
||||
|
||||
test('supplying custom theme', function (t) {
|
||||
cardinal.highlightFile(file, { theme: customTheme }, function (err, highlighted) {
|
||||
|
||||
t.equals(null, err, 'no error')
|
||||
t.equals(highlighted, '\u001b[94mfunction\u001b[39m \u001b[96mfoo\u001b[39m\u001b[90m(\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m \n \u001b[32mvar\u001b[39m \u001b[96ma\u001b[39m \u001b[93m=\u001b[39m \u001b[34m3\u001b[39m\u001b[90m;\u001b[39m \u001b[31mreturn\u001b[39m \u001b[96ma\u001b[39m \u001b[93m>\u001b[39m \u001b[34m2\u001b[39m \u001b[93m?\u001b[39m \u001b[31mtrue\u001b[39m \u001b[93m:\u001b[39m \u001b[91mfalse\u001b[39m\u001b[90m;\u001b[39m \n\u001b[33m}\u001b[39m\n')
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
test('not supplying custom theme', function (t) {
|
||||
cardinal.highlightFile(file, function (err, highlighted) {
|
||||
|
||||
t.equals(null, err, 'no error')
|
||||
t.equals(highlighted, '\u001b[94mfunction\u001b[39m \u001b[37mfoo\u001b[39m\u001b[90m(\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m \n \u001b[32mvar\u001b[39m \u001b[37ma\u001b[39m \u001b[93m=\u001b[39m \u001b[34m3\u001b[39m\u001b[90m;\u001b[39m \u001b[31mreturn\u001b[39m \u001b[37ma\u001b[39m \u001b[93m>\u001b[39m \u001b[34m2\u001b[39m \u001b[93m?\u001b[39m \u001b[91mtrue\u001b[39m \u001b[93m:\u001b[39m \u001b[91mfalse\u001b[39m\u001b[90m;\u001b[39m \n\u001b[33m}\u001b[39m\n')
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
test('syntactically invalid code', function (t) {
|
||||
cardinal.highlightFile(fileWithErrors, function (err, highlighted) {
|
||||
|
||||
t.equals(null, err, 'no error')
|
||||
t.equals(highlighted, '\u001b[94mfunction\u001b[39m \u001b[90m(\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m \n \u001b[32mvar\u001b[39m \u001b[37ma\u001b[39m \u001b[93m=\u001b[39m \u001b[34m3\u001b[39m\u001b[90m;\u001b[39m \u001b[31mreturn\u001b[39m \u001b[37ma\u001b[39m \u001b[93m>\u001b[39m \u001b[34m2\u001b[39m \u001b[93m?\u001b[39m \u001b[91mtrue\u001b[39m \u001b[93m:\u001b[39m \u001b[91mfalse\u001b[39m\u001b[90m;\u001b[39m \n\u001b[33m}\u001b[39m\u001b[90m;\u001b[39m\n')
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
test('non existing file', function (t) {
|
||||
cardinal.highlightFile('./not/existing', function (err, highlighted) {
|
||||
t.similar(err.message, /ENOENT. .*not.existing/)
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
45
node_modules/cardinal/test/cardinal-highlight-file-sync.js
generated
vendored
Normal file
45
node_modules/cardinal/test/cardinal-highlight-file-sync.js
generated
vendored
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
'use strict';
|
||||
/*jshint asi: true*/
|
||||
|
||||
var test = require('tap').test
|
||||
, util = require('util')
|
||||
, fs = require('fs')
|
||||
, path = require('path')
|
||||
, customTheme = require('./fixtures/custom')
|
||||
, cardinal = require('..')
|
||||
|
||||
function inspect (obj) {
|
||||
return console.log(util.inspect(obj, false, 5, false))
|
||||
}
|
||||
|
||||
var file = path.join(__dirname, 'fixtures/foo.js')
|
||||
, fileWithErrors = path.join(__dirname, 'fixtures/foo-with-errors.js')
|
||||
|
||||
test('supplying custom theme', function (t) {
|
||||
var highlighted = cardinal.highlightFileSync(file, { theme: customTheme });
|
||||
|
||||
t.equals(highlighted, '\u001b[94mfunction\u001b[39m \u001b[96mfoo\u001b[39m\u001b[90m(\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m \n \u001b[32mvar\u001b[39m \u001b[96ma\u001b[39m \u001b[93m=\u001b[39m \u001b[34m3\u001b[39m\u001b[90m;\u001b[39m \u001b[31mreturn\u001b[39m \u001b[96ma\u001b[39m \u001b[93m>\u001b[39m \u001b[34m2\u001b[39m \u001b[93m?\u001b[39m \u001b[31mtrue\u001b[39m \u001b[93m:\u001b[39m \u001b[91mfalse\u001b[39m\u001b[90m;\u001b[39m \n\u001b[33m}\u001b[39m\n')
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('not supplying custom theme', function (t) {
|
||||
var highlighted = cardinal.highlightFileSync(file);
|
||||
|
||||
t.equals(highlighted, '\u001b[94mfunction\u001b[39m \u001b[37mfoo\u001b[39m\u001b[90m(\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m \n \u001b[32mvar\u001b[39m \u001b[37ma\u001b[39m \u001b[93m=\u001b[39m \u001b[34m3\u001b[39m\u001b[90m;\u001b[39m \u001b[31mreturn\u001b[39m \u001b[37ma\u001b[39m \u001b[93m>\u001b[39m \u001b[34m2\u001b[39m \u001b[93m?\u001b[39m \u001b[91mtrue\u001b[39m \u001b[93m:\u001b[39m \u001b[91mfalse\u001b[39m\u001b[90m;\u001b[39m \n\u001b[33m}\u001b[39m\n')
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('syntactically invalid code', function (t) {
|
||||
var highlighted = cardinal.highlightFileSync(fileWithErrors);
|
||||
t.equals(highlighted, '\u001b[94mfunction\u001b[39m \u001b[90m(\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m \n \u001b[32mvar\u001b[39m \u001b[37ma\u001b[39m \u001b[93m=\u001b[39m \u001b[34m3\u001b[39m\u001b[90m;\u001b[39m \u001b[31mreturn\u001b[39m \u001b[37ma\u001b[39m \u001b[93m>\u001b[39m \u001b[34m2\u001b[39m \u001b[93m?\u001b[39m \u001b[91mtrue\u001b[39m \u001b[93m:\u001b[39m \u001b[91mfalse\u001b[39m\u001b[90m;\u001b[39m \n\u001b[33m}\u001b[39m\u001b[90m;\u001b[39m\n')
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('non existing file', function (t) {
|
||||
try {
|
||||
cardinal.highlightFileSync('./not/existing');
|
||||
} catch (e) {
|
||||
t.similar(e.message, /ENOENT. .*not.existing/)
|
||||
t.end()
|
||||
}
|
||||
})
|
||||
3
node_modules/cardinal/test/cardinal-highlight-git-diff.js
generated
vendored
Normal file
3
node_modules/cardinal/test/cardinal-highlight-git-diff.js
generated
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
|
||||
// Test Cases
|
||||
// highlightDiff('@@ -25,22 +31,47 @@ function resolveTheme (config) { }')
|
||||
22
node_modules/cardinal/test/cardinal-highlight-json-file-async.js
generated
vendored
Normal file
22
node_modules/cardinal/test/cardinal-highlight-json-file-async.js
generated
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
'use strict';
|
||||
/*jshint asi: true*/
|
||||
|
||||
var test = require('tap').test
|
||||
, util = require('util')
|
||||
, path = require('path')
|
||||
, cardinal = require('..')
|
||||
|
||||
function inspect (obj) {
|
||||
return console.log(util.inspect(obj, false, 5, false))
|
||||
}
|
||||
|
||||
var file = path.join(__dirname, 'fixtures/json.json');
|
||||
|
||||
test('without custom theme', function (t) {
|
||||
cardinal.highlightFile(file, function (err, highlighted) {
|
||||
|
||||
t.equals(null, err, 'no error');
|
||||
t.equals(highlighted, '\u001b[33m{\u001b[39m\u001b[32m"foo"\u001b[39m\u001b[93m:\u001b[39m\u001b[92m"bar"\u001b[39m\u001b[32m,\u001b[39m\u001b[32m"baz"\u001b[39m\u001b[93m:\u001b[39m\u001b[92m"quux"\u001b[39m\u001b[32m,\u001b[39m\u001b[32m"bam"\u001b[39m\u001b[93m:\u001b[39m\u001b[90mnull\u001b[39m\u001b[33m}\u001b[39m');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
20
node_modules/cardinal/test/cardinal-highlight-json-file-sync.js
generated
vendored
Normal file
20
node_modules/cardinal/test/cardinal-highlight-json-file-sync.js
generated
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
'use strict';
|
||||
/*jshint asi: true*/
|
||||
|
||||
var test = require('tap').test
|
||||
, util = require('util')
|
||||
, path = require('path')
|
||||
, cardinal = require('..')
|
||||
|
||||
function inspect (obj) {
|
||||
return console.log(util.inspect(obj, false, 5, false))
|
||||
}
|
||||
|
||||
var file = path.join(__dirname, 'fixtures/json.json');
|
||||
|
||||
test('without custom theme', function (t) {
|
||||
var highlighted = cardinal.highlightFileSync(file);
|
||||
|
||||
t.equals(highlighted, '\u001b[33m{\u001b[39m\u001b[32m"foo"\u001b[39m\u001b[93m:\u001b[39m\u001b[92m"bar"\u001b[39m\u001b[32m,\u001b[39m\u001b[32m"baz"\u001b[39m\u001b[93m:\u001b[39m\u001b[92m"quux"\u001b[39m\u001b[32m,\u001b[39m\u001b[32m"bam"\u001b[39m\u001b[93m:\u001b[39m\u001b[90mnull\u001b[39m\u001b[33m}\u001b[39m');
|
||||
t.end();
|
||||
});
|
||||
39
node_modules/cardinal/test/cardinal-highlight-json.js
generated
vendored
Normal file
39
node_modules/cardinal/test/cardinal-highlight-json.js
generated
vendored
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
'use strict';
|
||||
/*jshint asi: true*/
|
||||
|
||||
var test = require('tap').test
|
||||
, util = require('util')
|
||||
, customTheme = require('./fixtures/custom')
|
||||
, cardinal = require('..')
|
||||
|
||||
|
||||
function inspect (obj) {
|
||||
return console.log(util.inspect(obj, false, 5, false))
|
||||
}
|
||||
|
||||
var json = JSON.stringify({
|
||||
foo: 'bar',
|
||||
baz: 'quux',
|
||||
bam: null
|
||||
});
|
||||
|
||||
test('supplying custom theme', function (t) {
|
||||
var highlighted = cardinal.highlight(json, { theme: customTheme });
|
||||
|
||||
t.equals(highlighted, '\u001b[33m{\u001b[39m\u001b[92m"foo"\u001b[39m\u001b[93m:\u001b[39m\u001b[92m"bar"\u001b[39m\u001b[32m,\u001b[39m\u001b[92m"baz"\u001b[39m\u001b[93m:\u001b[39m\u001b[92m"quux"\u001b[39m\u001b[32m,\u001b[39m\u001b[92m"bam"\u001b[39m\u001b[93m:\u001b[39m\u001b[90mnull\u001b[39m\u001b[33m}\u001b[39m')
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('not supplying custom theme', function (t) {
|
||||
var highlighted = cardinal.highlight(json);
|
||||
|
||||
t.equals(highlighted, '\u001b[33m{\u001b[39m\u001b[32m"foo"\u001b[39m\u001b[93m:\u001b[39m\u001b[92m"bar"\u001b[39m\u001b[32m,\u001b[39m\u001b[32m"baz"\u001b[39m\u001b[93m:\u001b[39m\u001b[92m"quux"\u001b[39m\u001b[32m,\u001b[39m\u001b[32m"bam"\u001b[39m\u001b[93m:\u001b[39m\u001b[90mnull\u001b[39m\u001b[33m}\u001b[39m')
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('with the obsoleted json option (ignored)', function (t) {
|
||||
var highlighted = cardinal.highlight(json, { json: true });
|
||||
|
||||
t.equals(highlighted, '\u001b[33m{\u001b[39m\u001b[32m"foo"\u001b[39m\u001b[93m:\u001b[39m\u001b[92m"bar"\u001b[39m\u001b[32m,\u001b[39m\u001b[32m"baz"\u001b[39m\u001b[93m:\u001b[39m\u001b[92m"quux"\u001b[39m\u001b[32m,\u001b[39m\u001b[32m"bam"\u001b[39m\u001b[93m:\u001b[39m\u001b[90mnull\u001b[39m\u001b[33m}\u001b[39m')
|
||||
t.end();
|
||||
});
|
||||
68
node_modules/cardinal/test/cardinal-highlight-string.js
generated
vendored
Normal file
68
node_modules/cardinal/test/cardinal-highlight-string.js
generated
vendored
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
'use strict';
|
||||
/*jshint asi: true*/
|
||||
|
||||
var test = require('tap').test
|
||||
, util = require('util')
|
||||
, fs = require('fs')
|
||||
, customTheme = require('./fixtures/custom')
|
||||
, cardinal = require('..')
|
||||
|
||||
function inspect (obj) {
|
||||
return console.log(util.inspect(obj, false, 5, false))
|
||||
}
|
||||
|
||||
var code = 'function foo() { var a = 3; return a > 2 ? true : false; }'
|
||||
, codeWithErrors = 'function () { var a = 3; return a > 2 ? true : false; }';
|
||||
|
||||
test('supplying custom theme', function (t) {
|
||||
var highlighted = cardinal.highlight(code, { theme: customTheme });
|
||||
|
||||
t.equals(highlighted, '\u001b[94mfunction\u001b[39m \u001b[96mfoo\u001b[39m\u001b[90m(\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m \u001b[32mvar\u001b[39m \u001b[96ma\u001b[39m \u001b[93m=\u001b[39m \u001b[34m3\u001b[39m\u001b[90m;\u001b[39m \u001b[31mreturn\u001b[39m \u001b[96ma\u001b[39m \u001b[93m>\u001b[39m \u001b[34m2\u001b[39m \u001b[93m?\u001b[39m \u001b[31mtrue\u001b[39m \u001b[93m:\u001b[39m \u001b[91mfalse\u001b[39m\u001b[90m;\u001b[39m \u001b[33m}\u001b[39m')
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('not supplying custom theme', function (t) {
|
||||
var highlighted = cardinal.highlight(code);
|
||||
|
||||
t.equals(highlighted, '\u001b[94mfunction\u001b[39m \u001b[37mfoo\u001b[39m\u001b[90m(\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m \u001b[32mvar\u001b[39m \u001b[37ma\u001b[39m \u001b[93m=\u001b[39m \u001b[34m3\u001b[39m\u001b[90m;\u001b[39m \u001b[31mreturn\u001b[39m \u001b[37ma\u001b[39m \u001b[93m>\u001b[39m \u001b[34m2\u001b[39m \u001b[93m?\u001b[39m \u001b[91mtrue\u001b[39m \u001b[93m:\u001b[39m \u001b[91mfalse\u001b[39m\u001b[90m;\u001b[39m \u001b[33m}\u001b[39m')
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('syntactically invalid code', function (t) {
|
||||
var highlighted = cardinal.highlight(codeWithErrors);
|
||||
|
||||
t.equals(highlighted, '\u001b[94mfunction\u001b[39m \u001b[90m(\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m \u001b[32mvar\u001b[39m \u001b[37ma\u001b[39m \u001b[93m=\u001b[39m \u001b[34m3\u001b[39m\u001b[90m;\u001b[39m \u001b[31mreturn\u001b[39m \u001b[37ma\u001b[39m \u001b[93m>\u001b[39m \u001b[34m2\u001b[39m \u001b[93m?\u001b[39m \u001b[91mtrue\u001b[39m \u001b[93m:\u001b[39m \u001b[91mfalse\u001b[39m\u001b[90m;\u001b[39m \u001b[33m}\u001b[39m')
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('line numbers no firstline given', function (t) {
|
||||
var highlighted = cardinal.highlight(code, { linenos: true });
|
||||
t.equals(highlighted, '\u001b[90m1: \u001b[94mfunction\u001b[39m \u001b[37mfoo\u001b[39m\u001b[90m(\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m \u001b[32mvar\u001b[39m \u001b[37ma\u001b[39m \u001b[93m=\u001b[39m \u001b[34m3\u001b[39m\u001b[90m;\u001b[39m \u001b[31mreturn\u001b[39m \u001b[37ma\u001b[39m \u001b[93m>\u001b[39m \u001b[34m2\u001b[39m \u001b[93m?\u001b[39m \u001b[91mtrue\u001b[39m \u001b[93m:\u001b[39m \u001b[91mfalse\u001b[39m\u001b[90m;\u001b[39m \u001b[33m}\u001b[39m')
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('line numbers firstline 99', function (t) {
|
||||
var highlighted = cardinal.highlight(code, { linenos: true, firstline: 99 });
|
||||
t.equals(highlighted, '\u001b[90m99: \u001b[94mfunction\u001b[39m \u001b[37mfoo\u001b[39m\u001b[90m(\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m \u001b[32mvar\u001b[39m \u001b[37ma\u001b[39m \u001b[93m=\u001b[39m \u001b[34m3\u001b[39m\u001b[90m;\u001b[39m \u001b[31mreturn\u001b[39m \u001b[37ma\u001b[39m \u001b[93m>\u001b[39m \u001b[34m2\u001b[39m \u001b[93m?\u001b[39m \u001b[91mtrue\u001b[39m \u001b[93m:\u001b[39m \u001b[91mfalse\u001b[39m\u001b[90m;\u001b[39m \u001b[33m}\u001b[39m')
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('line numbers multi line no first line given', function (t) {
|
||||
var multilineCode = '' +
|
||||
function foo () {
|
||||
return 1;
|
||||
};
|
||||
var highlighted = cardinal.highlight(multilineCode, { linenos: true });
|
||||
t.equals(highlighted,'\u001b[90m1: \u001b[94mfunction\u001b[39m \u001b[37mfoo\u001b[39m\u001b[90m(\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m\n\u001b[90m2: \u001b[31mreturn\u001b[39m \u001b[34m1\u001b[39m\u001b[90m;\u001b[39m\n\u001b[90m3: \u001b[33m}\u001b[39m')
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('line numbers multi line first line 99', function (t) {
|
||||
var multilineCode = '' +
|
||||
function foo () {
|
||||
return 1;
|
||||
};
|
||||
var highlighted = cardinal.highlight(multilineCode, { linenos: true, firstline: 99 });
|
||||
t.equals(highlighted,'\u001b[90m 99: \u001b[94mfunction\u001b[39m \u001b[37mfoo\u001b[39m\u001b[90m(\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m\n\u001b[90m100: \u001b[31mreturn\u001b[39m \u001b[34m1\u001b[39m\u001b[90m;\u001b[39m\n\u001b[90m101: \u001b[33m}\u001b[39m')
|
||||
t.end()
|
||||
})
|
||||
44
node_modules/cardinal/test/cardinal-smoke.js
generated
vendored
Normal file
44
node_modules/cardinal/test/cardinal-smoke.js
generated
vendored
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
'use strict';
|
||||
/*jshint asi: true*/
|
||||
|
||||
// applying esprima to a bunch of files of contained libraries as a smoke test
|
||||
var test = require('tap').test
|
||||
, path = require('path')
|
||||
, fs = require('fs')
|
||||
, readdirp = require('readdirp')
|
||||
, cardinal = require('..')
|
||||
, node_modules = path.join(__dirname, '..', 'node_modules')
|
||||
, tapdir = path.join(node_modules, 'tap')
|
||||
, redeyeddir = path.join(node_modules, 'redeyed')
|
||||
|
||||
|
||||
test('tap', function (t) {
|
||||
var invalidTapFiles = [
|
||||
'async-map-ordered.js'
|
||||
, 'prof.js'
|
||||
]
|
||||
|
||||
readdirp({ root: tapdir, fileFilter: '*.js' })
|
||||
.on('data', function (entry) {
|
||||
|
||||
if (~invalidTapFiles.indexOf(entry.name)) return
|
||||
|
||||
var code = fs.readFileSync(entry.fullPath, 'utf-8')
|
||||
, result = cardinal.highlight(code);
|
||||
|
||||
t.assert(~result.indexOf('[32mvar\u001b[39m') || !(~result.indexOf('var ')), 'highlighted ' + entry.path)
|
||||
})
|
||||
.on('end', t.end.bind(t))
|
||||
})
|
||||
|
||||
test('redeyed', function (t) {
|
||||
readdirp({ root: redeyeddir, fileFilter: 'redeyed.js' })
|
||||
.on('data', function (entry) {
|
||||
|
||||
var code = fs.readFileSync(entry.fullPath, 'utf-8')
|
||||
, result = cardinal.highlight(code);
|
||||
|
||||
t.assert(~result.indexOf('[32mvar\u001b[39m') || !(~result.indexOf('var ')), 'highlighted ' + entry.path)
|
||||
})
|
||||
.on('end', t.end.bind(t))
|
||||
})
|
||||
14
node_modules/cardinal/test/fixtures/block-comment.js
generated
vendored
Normal file
14
node_modules/cardinal/test/fixtures/block-comment.js
generated
vendored
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
|
||||
/**
|
||||
* This is a meaningless block jsdoc for a meaningless function.
|
||||
* Joins two strings, separating them to appear on two lines.
|
||||
*
|
||||
* @name foo
|
||||
* @function
|
||||
* @param uno {String} first string
|
||||
* @param dos {String} second string
|
||||
* @return {String} result of the join
|
||||
*/
|
||||
module.exports = function foo (uno, dos) {
|
||||
return uno + '\n' + dos;
|
||||
}
|
||||
144
node_modules/cardinal/test/fixtures/custom.js
generated
vendored
Normal file
144
node_modules/cardinal/test/fixtures/custom.js
generated
vendored
Normal file
|
|
@ -0,0 +1,144 @@
|
|||
var colors = require('ansicolors');
|
||||
|
||||
// Change the below definitions in order to tweak the color theme.
|
||||
module.exports = {
|
||||
|
||||
'Boolean': {
|
||||
// changed from default
|
||||
'true' : colors.red
|
||||
|
||||
, 'false' : undefined
|
||||
, _default : colors.brightRed
|
||||
}
|
||||
|
||||
, 'Identifier': {
|
||||
'undefined' : colors.brightBlack
|
||||
, 'self' : colors.brightRed
|
||||
, 'console' : colors.blue
|
||||
, 'log' : colors.blue
|
||||
, 'warn' : colors.red
|
||||
, 'error' : colors.brightRed
|
||||
//
|
||||
// changed from default
|
||||
, _default : colors.brightCyan
|
||||
}
|
||||
|
||||
, 'Null': {
|
||||
_default: colors.brightBlack
|
||||
}
|
||||
|
||||
, 'Numeric': {
|
||||
_default: colors.blue
|
||||
}
|
||||
|
||||
, 'String': {
|
||||
_default: colors.brightGreen
|
||||
}
|
||||
|
||||
, 'Keyword': {
|
||||
'break' : undefined
|
||||
|
||||
, 'case' : undefined
|
||||
, 'catch' : colors.cyan
|
||||
, 'continue' : undefined
|
||||
|
||||
, 'debugger' : undefined
|
||||
, 'default' : undefined
|
||||
, 'delete' : colors.red
|
||||
, 'do' : undefined
|
||||
|
||||
, 'else' : undefined
|
||||
|
||||
, 'finally' : colors.cyan
|
||||
, 'for' : undefined
|
||||
, 'function' : undefined
|
||||
|
||||
, 'if' : undefined
|
||||
, 'in' : undefined
|
||||
, 'instanceof' : undefined
|
||||
|
||||
, 'new' : colors.red
|
||||
, 'return' : colors.red
|
||||
, 'switch' : undefined
|
||||
|
||||
, 'this' : colors.brightRed
|
||||
, 'throw' : undefined
|
||||
, 'try' : colors.cyan
|
||||
, 'typeof' : undefined
|
||||
|
||||
, 'var' : colors.green
|
||||
, 'void' : undefined
|
||||
|
||||
, 'while' : undefined
|
||||
, 'with' : undefined
|
||||
, _default : colors.brightBlue
|
||||
}
|
||||
, 'Punctuator': {
|
||||
';': colors.brightBlack
|
||||
, '.': colors.green
|
||||
, ',': colors.green
|
||||
|
||||
, '{': colors.yellow
|
||||
, '}': colors.yellow
|
||||
, '(': colors.brightBlack
|
||||
, ')': colors.brightBlack
|
||||
, '[': colors.yellow
|
||||
, ']': colors.yellow
|
||||
|
||||
, '<': undefined
|
||||
, '>': undefined
|
||||
, '+': undefined
|
||||
, '-': undefined
|
||||
, '*': undefined
|
||||
, '%': undefined
|
||||
, '&': undefined
|
||||
, '|': undefined
|
||||
, '^': undefined
|
||||
, '!': undefined
|
||||
, '~': undefined
|
||||
, '?': undefined
|
||||
, ':': undefined
|
||||
, '=': undefined
|
||||
|
||||
, '<=': undefined
|
||||
, '>=': undefined
|
||||
, '==': undefined
|
||||
, '!=': undefined
|
||||
, '++': undefined
|
||||
, '--': undefined
|
||||
, '<<': undefined
|
||||
, '>>': undefined
|
||||
, '&&': undefined
|
||||
, '||': undefined
|
||||
, '+=': undefined
|
||||
, '-=': undefined
|
||||
, '*=': undefined
|
||||
, '%=': undefined
|
||||
, '&=': undefined
|
||||
, '|=': undefined
|
||||
, '^=': undefined
|
||||
, '/=': undefined
|
||||
|
||||
, '===': undefined
|
||||
, '!==': undefined
|
||||
, '>>>': undefined
|
||||
, '<<=': undefined
|
||||
, '>>=': undefined
|
||||
|
||||
, '>>>=': undefined
|
||||
|
||||
, _default: colors.brightYellow
|
||||
}
|
||||
|
||||
// line comment
|
||||
, Line: {
|
||||
_default: colors.brightBlack
|
||||
}
|
||||
|
||||
/* block comment */
|
||||
, Block: {
|
||||
_default: colors.brightBlack
|
||||
}
|
||||
|
||||
, _default: undefined
|
||||
};
|
||||
3
node_modules/cardinal/test/fixtures/foo-with-errors.js
generated
vendored
Normal file
3
node_modules/cardinal/test/fixtures/foo-with-errors.js
generated
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
function () {
|
||||
var a = 3; return a > 2 ? true : false;
|
||||
};
|
||||
3
node_modules/cardinal/test/fixtures/foo.js
generated
vendored
Normal file
3
node_modules/cardinal/test/fixtures/foo.js
generated
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
function foo() {
|
||||
var a = 3; return a > 2 ? true : false;
|
||||
}
|
||||
78
node_modules/cardinal/test/fixtures/git-diff.txt
generated
vendored
Normal file
78
node_modules/cardinal/test/fixtures/git-diff.txt
generated
vendored
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
diff --git a/test/settings.js b/test/settings.js
|
||||
index 7b28d66..642688f 100644
|
||||
--- a/test/settings.js
|
||||
+++ b/test/settings.js
|
||||
@@ -1,14 +1,20 @@
|
||||
'use strict';
|
||||
/*jshint asi: true*/
|
||||
|
||||
-var test = require('tap').test
|
||||
- , path = require('path')
|
||||
- , fs = require('fs')
|
||||
- , settings = require('../settings')
|
||||
- , existsSync = fs.existsSync || path.existsSync
|
||||
+var test = require('tap').test
|
||||
+ , path = require('path')
|
||||
+ , fs = require('fs')
|
||||
, hideSemicolonsTheme = require('../themes/hide-semicolons')
|
||||
, home = path.join(__dirname, 'fixtures', 'home')
|
||||
, rcpath = path.join(home, '.cardinalrc')
|
||||
+ , existsSync = fs.existsSync || path.existsSync
|
||||
+ , settingsResolve = require.resolve('../settings')
|
||||
+ , settings
|
||||
+
|
||||
+function setup () {
|
||||
+ delete require.cache[settingsResolve]
|
||||
+ settings = require(settingsResolve)
|
||||
+}
|
||||
|
||||
function writerc(config) {
|
||||
fs.writeFileSync(rcpath, JSON.stringify(config), 'utf-8')
|
||||
@@ -25,22 +31,47 @@ function resolveTheme (config) {
|
||||
return result;
|
||||
}
|
||||
|
||||
+function getSettings (config) {
|
||||
+ writerc(config)
|
||||
+ var result = settings.getSettings(home)
|
||||
+ removerc()
|
||||
+ return result;
|
||||
+}
|
||||
+
|
||||
if (!existsSync(home)) fs.mkdirSync(home);
|
||||
|
||||
test('no .cardinalrc in home', function (t) {
|
||||
+ setup()
|
||||
var theme = settings.resolveTheme(home)
|
||||
t.equals(theme, undefined, 'resolves no theme')
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('.cardinalrc with theme "hide-semicolons" in home', function (t) {
|
||||
+ setup()
|
||||
var theme = resolveTheme({ theme: "hide-semicolons" })
|
||||
t.deepEquals(theme, hideSemicolonsTheme, 'resolves hide-semicolons theme')
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('.cardinalrc with full path to "hide-semicolons.js" in home', function (t) {
|
||||
+ setup()
|
||||
var theme = resolveTheme({ theme: path.join(__dirname, '..', 'themes', 'hide-semicolons.js') })
|
||||
t.deepEquals(theme, hideSemicolonsTheme, 'resolves hide-semicolons theme')
|
||||
t.end()
|
||||
})
|
||||
+
|
||||
+test('.cardinalrc with linenos: true', function (t) {
|
||||
+ setup()
|
||||
+ var opts = { linenos: true }
|
||||
+ t.deepEquals(getSettings(opts), opts)
|
||||
+ t.end()
|
||||
+})
|
||||
+
|
||||
+test('.cardinalrc with linenos: true and theme', function (t) {
|
||||
+ setup()
|
||||
+ var opts = { linenos: true, theme: 'some theme' }
|
||||
+ t.deepEquals(getSettings(opts), opts)
|
||||
+ t.end()
|
||||
+})
|
||||
+
|
||||
1
node_modules/cardinal/test/fixtures/json.json
generated
vendored
Normal file
1
node_modules/cardinal/test/fixtures/json.json
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"foo":"bar","baz":"quux","bam":null}
|
||||
23
node_modules/cardinal/test/fixtures/svn-diff.txt
generated
vendored
Normal file
23
node_modules/cardinal/test/fixtures/svn-diff.txt
generated
vendored
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
Index: grunt.js
|
||||
===================================================================
|
||||
--- grunt.js (revision 31200)
|
||||
+++ grunt.js (working copy)
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
module.exports = function (grunt) {
|
||||
|
||||
+ console.log('hello world');
|
||||
// Project configuration.
|
||||
grunt.initConfig({
|
||||
lint: {
|
||||
@@ -19,10 +20,6 @@
|
||||
'packages/services.web/{!(test)/**/,}*.js',
|
||||
'packages/error/**/*.js'
|
||||
],
|
||||
- scripts: [
|
||||
- 'grunt.js',
|
||||
- 'db/**/*.js'
|
||||
- ],
|
||||
browser: [
|
||||
'packages/web/server.js',
|
||||
'packages/web/server/**/*.js',
|
||||
77
node_modules/cardinal/test/settings.js
generated
vendored
Normal file
77
node_modules/cardinal/test/settings.js
generated
vendored
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
'use strict';
|
||||
/*jshint asi: true*/
|
||||
|
||||
var test = require('tap').test
|
||||
, path = require('path')
|
||||
, fs = require('fs')
|
||||
, hideSemicolonsTheme = require('../themes/hide-semicolons')
|
||||
, home = path.join(__dirname, 'fixtures', 'home')
|
||||
, rcpath = path.join(home, '.cardinalrc')
|
||||
, existsSync = fs.existsSync || path.existsSync
|
||||
, settingsResolve = require.resolve('../settings')
|
||||
, settings
|
||||
|
||||
function setup () {
|
||||
delete require.cache[settingsResolve]
|
||||
settings = require(settingsResolve)
|
||||
}
|
||||
|
||||
function writerc(config) {
|
||||
fs.writeFileSync(rcpath, JSON.stringify(config), 'utf-8')
|
||||
}
|
||||
|
||||
function removerc () {
|
||||
fs.unlinkSync(rcpath)
|
||||
}
|
||||
|
||||
function resolveTheme (config) {
|
||||
writerc(config)
|
||||
var result = settings.resolveTheme(home)
|
||||
removerc()
|
||||
return result;
|
||||
}
|
||||
|
||||
function getSettings (config) {
|
||||
writerc(config)
|
||||
var result = settings.getSettings(home)
|
||||
removerc()
|
||||
return result;
|
||||
}
|
||||
|
||||
if (!existsSync(home)) fs.mkdirSync(home);
|
||||
|
||||
test('no .cardinalrc in home', function (t) {
|
||||
setup()
|
||||
var theme = settings.resolveTheme(home)
|
||||
t.equals(theme, undefined, 'resolves no theme')
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('.cardinalrc with theme "hide-semicolons" in home', function (t) {
|
||||
setup()
|
||||
var theme = resolveTheme({ theme: "hide-semicolons" })
|
||||
t.deepEquals(theme, hideSemicolonsTheme, 'resolves hide-semicolons theme')
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('.cardinalrc with full path to "hide-semicolons.js" in home', function (t) {
|
||||
setup()
|
||||
var theme = resolveTheme({ theme: path.join(__dirname, '..', 'themes', 'hide-semicolons.js') })
|
||||
t.deepEquals(theme, hideSemicolonsTheme, 'resolves hide-semicolons theme')
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('.cardinalrc with linenos: true', function (t) {
|
||||
setup()
|
||||
var opts = { linenos: true }
|
||||
t.deepEquals(getSettings(opts), opts)
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('.cardinalrc with linenos: true and theme', function (t) {
|
||||
setup()
|
||||
var opts = { linenos: true, theme: 'some theme' }
|
||||
t.deepEquals(getSettings(opts), opts)
|
||||
t.end()
|
||||
})
|
||||
|
||||
22
node_modules/cardinal/test/themes.js
generated
vendored
Normal file
22
node_modules/cardinal/test/themes.js
generated
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
'use strict';
|
||||
/*jshint asi: true*/
|
||||
|
||||
var test = require('tap').test
|
||||
, path = require('path')
|
||||
, fs = require('fs')
|
||||
, themesdir = path.join(__dirname, '..', 'themes')
|
||||
, allFiles = fs.readdirSync(themesdir)
|
||||
|
||||
test('validate themes by requiring all of them', function (t) {
|
||||
allFiles
|
||||
.filter(function (file) { return path.extname(file) === '.js'; })
|
||||
.forEach(function (theme) {
|
||||
try {
|
||||
t.ok(require(path.join(themesdir, theme)), theme + ' is valid')
|
||||
} catch (e) {
|
||||
t.fail('theme: ' + theme + ' is invalid! ' + e.message)
|
||||
}
|
||||
})
|
||||
t.end()
|
||||
})
|
||||
|
||||
31
node_modules/cardinal/themes/README.md
generated
vendored
Normal file
31
node_modules/cardinal/themes/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
# cardinal themes
|
||||
|
||||
These are the built in themes that come with cardinal.
|
||||
|
||||
You can create more themes by copying and then editing the [empty
|
||||
theme](https://github.com/thlorenz/cardinal/blob/master/themes/empty.js) which is provided for that purpose.
|
||||
|
||||
The [hide semicolons theme](https://github.com/thlorenz/cardinal/blob/master/themes/hide-semicolons.js) has the added
|
||||
benefit of making all semicolons invisible. This makes code more readable at times.
|
||||
|
||||
Find out how to change the theme used by cardinal [here](https://github.com/thlorenz/cardinal#theme).
|
||||
|
||||
# sharing themes
|
||||
|
||||
To add your theme to the cardinal built-in themes, follow the below steps:
|
||||
|
||||
1. fork the cardinal repository
|
||||
2. add your theme to the themes folder and commit your changes
|
||||
3. create a pull request
|
||||
|
||||
If you believe that your theme is better than the current default theme, let me know by creating an issue.
|
||||
|
||||
This will allow others to cast their vote. If enough people agree, your theme will be promoted to be the default.
|
||||
|
||||
## Contributed Themes
|
||||
|
||||
### tomorrow night
|
||||
|
||||
[](https://github.com/thlorenz/cardinal/blob/master/themes/tomorrow-night.js)
|
||||
|
||||
*by [firede](https://github.com/firede)*
|
||||
163
node_modules/cardinal/themes/default.js
generated
vendored
Normal file
163
node_modules/cardinal/themes/default.js
generated
vendored
Normal file
|
|
@ -0,0 +1,163 @@
|
|||
var colors = require('ansicolors');
|
||||
|
||||
// Change the below definitions in order to tweak the color theme.
|
||||
module.exports = {
|
||||
|
||||
'Boolean': {
|
||||
'true' : undefined
|
||||
, 'false' : undefined
|
||||
, _default : colors.brightRed
|
||||
}
|
||||
|
||||
, 'Identifier': {
|
||||
'undefined' : colors.brightBlack
|
||||
, 'self' : colors.brightRed
|
||||
, 'console' : colors.blue
|
||||
, 'log' : colors.blue
|
||||
, 'warn' : colors.red
|
||||
, 'error' : colors.brightRed
|
||||
, _default : colors.white
|
||||
}
|
||||
|
||||
, 'Null': {
|
||||
_default: colors.brightBlack
|
||||
}
|
||||
|
||||
, 'Numeric': {
|
||||
_default: colors.blue
|
||||
}
|
||||
|
||||
, 'String': {
|
||||
_default: function (s, info) {
|
||||
var nextToken = info.tokens[info.tokenIndex + 1];
|
||||
|
||||
// show keys of object literals and json in different color
|
||||
return (nextToken && nextToken.type === 'Punctuator' && nextToken.value === ':')
|
||||
? colors.green(s)
|
||||
: colors.brightGreen(s);
|
||||
}
|
||||
}
|
||||
|
||||
, 'Keyword': {
|
||||
'break' : undefined
|
||||
|
||||
, 'case' : undefined
|
||||
, 'catch' : colors.cyan
|
||||
, 'class' : undefined
|
||||
, 'const' : undefined
|
||||
, 'continue' : undefined
|
||||
|
||||
, 'debugger' : undefined
|
||||
, 'default' : undefined
|
||||
, 'delete' : colors.red
|
||||
, 'do' : undefined
|
||||
|
||||
, 'else' : undefined
|
||||
, 'enum' : undefined
|
||||
, 'export' : undefined
|
||||
, 'extends' : undefined
|
||||
|
||||
, 'finally' : colors.cyan
|
||||
, 'for' : undefined
|
||||
, 'function' : undefined
|
||||
|
||||
, 'if' : undefined
|
||||
, 'implements' : undefined
|
||||
, 'import' : undefined
|
||||
, 'in' : undefined
|
||||
, 'instanceof' : undefined
|
||||
, 'let' : undefined
|
||||
, 'new' : colors.red
|
||||
, 'package' : undefined
|
||||
, 'private' : undefined
|
||||
, 'protected' : undefined
|
||||
, 'public' : undefined
|
||||
, 'return' : colors.red
|
||||
, 'static' : undefined
|
||||
, 'super' : undefined
|
||||
, 'switch' : undefined
|
||||
|
||||
, 'this' : colors.brightRed
|
||||
, 'throw' : undefined
|
||||
, 'try' : colors.cyan
|
||||
, 'typeof' : undefined
|
||||
|
||||
, 'var' : colors.green
|
||||
, 'void' : undefined
|
||||
|
||||
, 'while' : undefined
|
||||
, 'with' : undefined
|
||||
, 'yield' : undefined
|
||||
, _default : colors.brightBlue
|
||||
}
|
||||
, 'Punctuator': {
|
||||
';': colors.brightBlack
|
||||
, '.': colors.green
|
||||
, ',': colors.green
|
||||
|
||||
, '{': colors.yellow
|
||||
, '}': colors.yellow
|
||||
, '(': colors.brightBlack
|
||||
, ')': colors.brightBlack
|
||||
, '[': colors.yellow
|
||||
, ']': colors.yellow
|
||||
|
||||
, '<': undefined
|
||||
, '>': undefined
|
||||
, '+': undefined
|
||||
, '-': undefined
|
||||
, '*': undefined
|
||||
, '%': undefined
|
||||
, '&': undefined
|
||||
, '|': undefined
|
||||
, '^': undefined
|
||||
, '!': undefined
|
||||
, '~': undefined
|
||||
, '?': undefined
|
||||
, ':': undefined
|
||||
, '=': undefined
|
||||
|
||||
, '<=': undefined
|
||||
, '>=': undefined
|
||||
, '==': undefined
|
||||
, '!=': undefined
|
||||
, '++': undefined
|
||||
, '--': undefined
|
||||
, '<<': undefined
|
||||
, '>>': undefined
|
||||
, '&&': undefined
|
||||
, '||': undefined
|
||||
, '+=': undefined
|
||||
, '-=': undefined
|
||||
, '*=': undefined
|
||||
, '%=': undefined
|
||||
, '&=': undefined
|
||||
, '|=': undefined
|
||||
, '^=': undefined
|
||||
, '/=': undefined
|
||||
, '=>': undefined
|
||||
|
||||
, '===': undefined
|
||||
, '!==': undefined
|
||||
, '>>>': undefined
|
||||
, '<<=': undefined
|
||||
, '>>=': undefined
|
||||
, '...': undefined
|
||||
|
||||
, '>>>=': undefined
|
||||
|
||||
, _default: colors.brightYellow
|
||||
}
|
||||
|
||||
// line comment
|
||||
, Line: {
|
||||
_default: colors.brightBlack
|
||||
}
|
||||
|
||||
/* block comment */
|
||||
, Block: {
|
||||
_default: colors.brightBlack
|
||||
}
|
||||
|
||||
, _default: undefined
|
||||
};
|
||||
159
node_modules/cardinal/themes/empty.js
generated
vendored
Normal file
159
node_modules/cardinal/themes/empty.js
generated
vendored
Normal file
|
|
@ -0,0 +1,159 @@
|
|||
/*
|
||||
* Copy this file and use it as a starting point for your custom cardinal color theme.
|
||||
* Just fill in or change the entries for the tokens you want to color
|
||||
* Keep in mind that more specific configurations override less specific ones.
|
||||
*/
|
||||
|
||||
var colors = require('ansicolors');
|
||||
|
||||
// Change the below definitions in order to tweak the color theme.
|
||||
module.exports = {
|
||||
|
||||
'Boolean': {
|
||||
'true' : undefined
|
||||
, 'false' : undefined
|
||||
, _default : undefined
|
||||
}
|
||||
|
||||
, 'Identifier': {
|
||||
_default: undefined
|
||||
}
|
||||
|
||||
, 'Null': {
|
||||
_default: undefined
|
||||
}
|
||||
|
||||
, 'Numeric': {
|
||||
_default: undefined
|
||||
}
|
||||
|
||||
, 'String': {
|
||||
_default: undefined
|
||||
}
|
||||
|
||||
, 'Keyword': {
|
||||
'break' : undefined
|
||||
|
||||
, 'case' : undefined
|
||||
, 'catch' : undefined
|
||||
, 'class' : undefined
|
||||
, 'const' : undefined
|
||||
, 'continue' : undefined
|
||||
|
||||
, 'debugger' : undefined
|
||||
, 'default' : undefined
|
||||
, 'delete' : undefined
|
||||
, 'do' : undefined
|
||||
|
||||
, 'else' : undefined
|
||||
, 'enum' : undefined
|
||||
, 'export' : undefined
|
||||
, 'extends' : undefined
|
||||
|
||||
, 'finally' : undefined
|
||||
, 'for' : undefined
|
||||
, 'function' : undefined
|
||||
|
||||
, 'if' : undefined
|
||||
, 'implements' : undefined
|
||||
, 'import' : undefined
|
||||
, 'in' : undefined
|
||||
, 'instanceof' : undefined
|
||||
, 'interface' : undefined
|
||||
, 'let' : undefined
|
||||
, 'new' : undefined
|
||||
|
||||
, 'package' : undefined
|
||||
, 'private' : undefined
|
||||
, 'protected' : undefined
|
||||
, 'public' : undefined
|
||||
|
||||
, 'return' : undefined
|
||||
, 'static' : undefined
|
||||
, 'super' : undefined
|
||||
, 'switch' : undefined
|
||||
|
||||
, 'this' : undefined
|
||||
, 'throw' : undefined
|
||||
, 'try' : undefined
|
||||
, 'typeof' : undefined
|
||||
|
||||
, 'var' : undefined
|
||||
, 'void' : undefined
|
||||
|
||||
, 'while' : undefined
|
||||
, 'with' : undefined
|
||||
, 'yield' : undefined
|
||||
, _default : undefined
|
||||
}
|
||||
, 'Punctuator': {
|
||||
';': undefined
|
||||
, '.': undefined
|
||||
, ',': undefined
|
||||
|
||||
, '{': undefined
|
||||
, '}': undefined
|
||||
, '(': undefined
|
||||
, ')': undefined
|
||||
, '[': undefined
|
||||
, ']': undefined
|
||||
|
||||
, '<': undefined
|
||||
, '>': undefined
|
||||
, '+': undefined
|
||||
, '-': undefined
|
||||
, '*': undefined
|
||||
, '%': undefined
|
||||
, '&': undefined
|
||||
, '|': undefined
|
||||
, '^': undefined
|
||||
, '!': undefined
|
||||
, '~': undefined
|
||||
, '?': undefined
|
||||
, ':': undefined
|
||||
, '=': undefined
|
||||
|
||||
, '<=': undefined
|
||||
, '>=': undefined
|
||||
, '==': undefined
|
||||
, '!=': undefined
|
||||
, '++': undefined
|
||||
, '--': undefined
|
||||
, '<<': undefined
|
||||
, '>>': undefined
|
||||
, '&&': undefined
|
||||
, '||': undefined
|
||||
, '+=': undefined
|
||||
, '-=': undefined
|
||||
, '*=': undefined
|
||||
, '%=': undefined
|
||||
, '&=': undefined
|
||||
, '|=': undefined
|
||||
, '^=': undefined
|
||||
, '/=': undefined
|
||||
, '=>': undefined
|
||||
|
||||
, '===': undefined
|
||||
, '!==': undefined
|
||||
, '>>>': undefined
|
||||
, '<<=': undefined
|
||||
, '>>=': undefined
|
||||
, '...': undefined
|
||||
|
||||
, '>>>=': undefined
|
||||
|
||||
, _default: undefined
|
||||
}
|
||||
|
||||
// line comment
|
||||
, Line: {
|
||||
_default: undefined
|
||||
}
|
||||
|
||||
/* block comment */
|
||||
, Block: {
|
||||
_default: undefined
|
||||
}
|
||||
|
||||
, _default: undefined
|
||||
};
|
||||
165
node_modules/cardinal/themes/hide-semicolons.js
generated
vendored
Normal file
165
node_modules/cardinal/themes/hide-semicolons.js
generated
vendored
Normal file
|
|
@ -0,0 +1,165 @@
|
|||
var colors = require('ansicolors');
|
||||
|
||||
// Change the below definitions in order to tweak the color theme.
|
||||
module.exports = {
|
||||
|
||||
'Boolean': {
|
||||
'true' : undefined
|
||||
, 'false' : undefined
|
||||
, _default : colors.brightRed
|
||||
}
|
||||
|
||||
, 'Identifier': {
|
||||
'undefined' : colors.brightBlack
|
||||
, 'self' : colors.brightRed
|
||||
, 'console' : colors.blue
|
||||
, 'log' : colors.blue
|
||||
, 'warn' : colors.red
|
||||
, 'error' : colors.brightRed
|
||||
, _default : colors.white
|
||||
}
|
||||
|
||||
, 'Null': {
|
||||
_default: colors.brightBlack
|
||||
}
|
||||
|
||||
, 'Numeric': {
|
||||
_default: colors.blue
|
||||
}
|
||||
|
||||
, 'String': {
|
||||
_default: function (s, info) {
|
||||
var nextToken = info.tokens[info.tokenIndex + 1];
|
||||
|
||||
// show keys of object literals and json in different color
|
||||
return (nextToken && nextToken.type === 'Punctuator' && nextToken.value === ':')
|
||||
? colors.green(s)
|
||||
: colors.brightGreen(s);
|
||||
}
|
||||
}
|
||||
|
||||
, 'Keyword': {
|
||||
'break' : undefined
|
||||
|
||||
, 'case' : undefined
|
||||
, 'catch' : colors.cyan
|
||||
, 'class' : undefined
|
||||
, 'const' : undefined
|
||||
, 'continue' : undefined
|
||||
|
||||
, 'debugger' : undefined
|
||||
, 'default' : undefined
|
||||
, 'delete' : colors.red
|
||||
, 'do' : undefined
|
||||
|
||||
, 'else' : undefined
|
||||
, 'enum' : undefined
|
||||
, 'export' : undefined
|
||||
, 'extends' : undefined
|
||||
|
||||
, 'finally' : colors.cyan
|
||||
, 'for' : undefined
|
||||
, 'function' : undefined
|
||||
|
||||
, 'if' : undefined
|
||||
, 'implements' : undefined
|
||||
, 'import' : undefined
|
||||
, 'in' : undefined
|
||||
, 'instanceof' : undefined
|
||||
, 'let' : undefined
|
||||
, 'new' : colors.red
|
||||
, 'package' : undefined
|
||||
, 'private' : undefined
|
||||
, 'protected' : undefined
|
||||
, 'public' : undefined
|
||||
, 'return' : colors.red
|
||||
, 'static' : undefined
|
||||
, 'super' : undefined
|
||||
, 'switch' : undefined
|
||||
|
||||
, 'this' : colors.brightRed
|
||||
, 'throw' : undefined
|
||||
, 'try' : colors.cyan
|
||||
, 'typeof' : undefined
|
||||
|
||||
, 'var' : colors.green
|
||||
, 'void' : undefined
|
||||
|
||||
, 'while' : undefined
|
||||
, 'with' : undefined
|
||||
, 'yield' : undefined
|
||||
, _default : colors.brightBlue
|
||||
}
|
||||
, 'Punctuator': {
|
||||
// setting semicolon's color to the same as the terminal background makes it invisible
|
||||
';': colors.black
|
||||
|
||||
, '.': colors.green
|
||||
, ',': colors.green
|
||||
|
||||
, '{': colors.yellow
|
||||
, '}': colors.yellow
|
||||
, '(': colors.brightBlack
|
||||
, ')': colors.brightBlack
|
||||
, '[': colors.yellow
|
||||
, ']': colors.yellow
|
||||
|
||||
, '<': undefined
|
||||
, '>': undefined
|
||||
, '+': undefined
|
||||
, '-': undefined
|
||||
, '*': undefined
|
||||
, '%': undefined
|
||||
, '&': undefined
|
||||
, '|': undefined
|
||||
, '^': undefined
|
||||
, '!': undefined
|
||||
, '~': undefined
|
||||
, '?': undefined
|
||||
, ':': undefined
|
||||
, '=': undefined
|
||||
|
||||
, '<=': undefined
|
||||
, '>=': undefined
|
||||
, '==': undefined
|
||||
, '!=': undefined
|
||||
, '++': undefined
|
||||
, '--': undefined
|
||||
, '<<': undefined
|
||||
, '>>': undefined
|
||||
, '&&': undefined
|
||||
, '||': undefined
|
||||
, '+=': undefined
|
||||
, '-=': undefined
|
||||
, '*=': undefined
|
||||
, '%=': undefined
|
||||
, '&=': undefined
|
||||
, '|=': undefined
|
||||
, '^=': undefined
|
||||
, '/=': undefined
|
||||
, '=>': undefined
|
||||
|
||||
, '===': undefined
|
||||
, '!==': undefined
|
||||
, '>>>': undefined
|
||||
, '<<=': undefined
|
||||
, '>>=': undefined
|
||||
, '...': undefined
|
||||
|
||||
, '>>>=': undefined
|
||||
|
||||
, _default: colors.brightYellow
|
||||
}
|
||||
|
||||
// line comment
|
||||
, Line: {
|
||||
_default: colors.brightBlack
|
||||
}
|
||||
|
||||
/* block comment */
|
||||
, Block: {
|
||||
_default: colors.brightBlack
|
||||
}
|
||||
|
||||
, _default: undefined
|
||||
};
|
||||
167
node_modules/cardinal/themes/jq.js
generated
vendored
Normal file
167
node_modules/cardinal/themes/jq.js
generated
vendored
Normal file
|
|
@ -0,0 +1,167 @@
|
|||
var colors = require('ansicolors');
|
||||
|
||||
// mimics [jq](https://stedolan.github.io/jq/) highlighting for json files
|
||||
// mainly in the fact that the keys are a clearly different color than the strings
|
||||
// However improvements to this theme are highly welcome! :)
|
||||
|
||||
// Change the below definitions in order to tweak the color theme.
|
||||
module.exports = {
|
||||
|
||||
'Boolean': {
|
||||
'true' : undefined
|
||||
, 'false' : undefined
|
||||
, _default : colors.brightRed
|
||||
}
|
||||
|
||||
, 'Identifier': {
|
||||
'undefined' : colors.brightBlack
|
||||
, 'self' : colors.brightRed
|
||||
, 'console' : colors.blue
|
||||
, 'log' : colors.blue
|
||||
, 'warn' : colors.red
|
||||
, 'error' : colors.brightRed
|
||||
, _default : colors.white
|
||||
}
|
||||
|
||||
, 'Null': {
|
||||
_default: colors.brightBlack
|
||||
}
|
||||
|
||||
, 'Numeric': {
|
||||
_default: colors.blue
|
||||
}
|
||||
|
||||
, 'String': {
|
||||
_default: function (s, info) {
|
||||
var nextToken = info.tokens[info.tokenIndex + 1];
|
||||
|
||||
// show keys of object literals and json in different color
|
||||
return (nextToken && nextToken.type === 'Punctuator' && nextToken.value === ':')
|
||||
? colors.brightBlue(s)
|
||||
: colors.brightGreen(s);
|
||||
}
|
||||
}
|
||||
|
||||
, 'Keyword': {
|
||||
'break' : undefined
|
||||
|
||||
, 'case' : undefined
|
||||
, 'catch' : colors.cyan
|
||||
, 'class' : undefined
|
||||
, 'const' : undefined
|
||||
, 'continue' : undefined
|
||||
|
||||
, 'debugger' : undefined
|
||||
, 'default' : undefined
|
||||
, 'delete' : colors.red
|
||||
, 'do' : undefined
|
||||
|
||||
, 'else' : undefined
|
||||
, 'enum' : undefined
|
||||
, 'export' : undefined
|
||||
, 'extends' : undefined
|
||||
|
||||
, 'finally' : colors.cyan
|
||||
, 'for' : undefined
|
||||
, 'function' : undefined
|
||||
|
||||
, 'if' : undefined
|
||||
, 'implements' : undefined
|
||||
, 'import' : undefined
|
||||
, 'in' : undefined
|
||||
, 'instanceof' : undefined
|
||||
, 'let' : undefined
|
||||
, 'new' : colors.red
|
||||
, 'package' : undefined
|
||||
, 'private' : undefined
|
||||
, 'protected' : undefined
|
||||
, 'public' : undefined
|
||||
, 'return' : colors.red
|
||||
, 'static' : undefined
|
||||
, 'super' : undefined
|
||||
, 'switch' : undefined
|
||||
|
||||
, 'this' : colors.brightRed
|
||||
, 'throw' : undefined
|
||||
, 'try' : colors.cyan
|
||||
, 'typeof' : undefined
|
||||
|
||||
, 'var' : colors.green
|
||||
, 'void' : undefined
|
||||
|
||||
, 'while' : undefined
|
||||
, 'with' : undefined
|
||||
, 'yield' : undefined
|
||||
, _default : colors.brightBlue
|
||||
}
|
||||
, 'Punctuator': {
|
||||
';': colors.brightBlack
|
||||
, '.': colors.green
|
||||
, ',': colors.green
|
||||
|
||||
, '{': colors.brightWhite
|
||||
, '}': colors.brightWhite
|
||||
, '(': colors.brightBlack
|
||||
, ')': colors.brightBlack
|
||||
, '[': colors.brightWhite
|
||||
, ']': colors.brightWhite
|
||||
|
||||
, '<': undefined
|
||||
, '>': undefined
|
||||
, '+': undefined
|
||||
, '-': undefined
|
||||
, '*': undefined
|
||||
, '%': undefined
|
||||
, '&': undefined
|
||||
, '|': undefined
|
||||
, '^': undefined
|
||||
, '!': undefined
|
||||
, '~': undefined
|
||||
, '?': undefined
|
||||
, ':': undefined
|
||||
, '=': undefined
|
||||
|
||||
, '<=': undefined
|
||||
, '>=': undefined
|
||||
, '==': undefined
|
||||
, '!=': undefined
|
||||
, '++': undefined
|
||||
, '--': undefined
|
||||
, '<<': undefined
|
||||
, '>>': undefined
|
||||
, '&&': undefined
|
||||
, '||': undefined
|
||||
, '+=': undefined
|
||||
, '-=': undefined
|
||||
, '*=': undefined
|
||||
, '%=': undefined
|
||||
, '&=': undefined
|
||||
, '|=': undefined
|
||||
, '^=': undefined
|
||||
, '/=': undefined
|
||||
, '=>': undefined
|
||||
|
||||
, '===': undefined
|
||||
, '!==': undefined
|
||||
, '>>>': undefined
|
||||
, '<<=': undefined
|
||||
, '>>=': undefined
|
||||
, '...': undefined
|
||||
|
||||
, '>>>=': undefined
|
||||
|
||||
, _default: colors.brightYellow
|
||||
}
|
||||
|
||||
// line comment
|
||||
, Line: {
|
||||
_default: colors.brightBlack
|
||||
}
|
||||
|
||||
/* block comment */
|
||||
, Block: {
|
||||
_default: colors.brightBlack
|
||||
}
|
||||
|
||||
, _default: undefined
|
||||
};
|
||||
177
node_modules/cardinal/themes/tomorrow-night.js
generated
vendored
Normal file
177
node_modules/cardinal/themes/tomorrow-night.js
generated
vendored
Normal file
|
|
@ -0,0 +1,177 @@
|
|||
var colors = require('ansicolors');
|
||||
|
||||
// Change the below definitions in order to tweak the color theme.
|
||||
module.exports = {
|
||||
|
||||
'Boolean': {
|
||||
'true' : undefined
|
||||
, 'false' : undefined
|
||||
, _default : colors.yellow
|
||||
}
|
||||
|
||||
, 'Identifier': {
|
||||
'undefined' : colors.yellow
|
||||
, 'self' : colors.yellow
|
||||
, 'type' : colors.yellow
|
||||
, 'value' : colors.yellow
|
||||
, 'console' : undefined
|
||||
, 'log' : colors.blue
|
||||
, 'warn' : colors.blue
|
||||
, 'error' : colors.blue
|
||||
, 'join' : colors.blue
|
||||
, _default : function (s, info) {
|
||||
var prevToken = info.tokens[info.tokenIndex - 1];
|
||||
var nextToken = info.tokens[info.tokenIndex + 1];
|
||||
|
||||
return (nextToken
|
||||
&& nextToken.type === 'Punctuator'
|
||||
&& nextToken.value === '('
|
||||
&& prevToken
|
||||
&& prevToken.type === 'Keyword'
|
||||
&& prevToken.value === 'function'
|
||||
) ? colors.blue(s) : colors.white(s);
|
||||
}
|
||||
}
|
||||
|
||||
, 'Null': {
|
||||
_default: colors.yellow
|
||||
}
|
||||
|
||||
, 'Numeric': {
|
||||
_default: colors.yellow
|
||||
}
|
||||
|
||||
, 'String': {
|
||||
_default: function (s, info) {
|
||||
var nextToken = info.tokens[info.tokenIndex + 1];
|
||||
|
||||
// show keys of object literals and json in different color
|
||||
return (nextToken && nextToken.type === 'Punctuator' && nextToken.value === ':')
|
||||
? colors.green(s)
|
||||
: colors.brightGreen(s);
|
||||
}
|
||||
}
|
||||
|
||||
, 'Keyword': {
|
||||
'break' : colors.magenta
|
||||
|
||||
, 'case' : colors.magenta
|
||||
, 'catch' : colors.magenta
|
||||
, 'class' : undefined
|
||||
, 'const' : undefined
|
||||
, 'continue' : colors.magenta
|
||||
|
||||
, 'debugger' : colors.magenta
|
||||
, 'default' : colors.magenta
|
||||
, 'delete' : colors.red
|
||||
, 'do' : colors.magenta
|
||||
|
||||
, 'else' : colors.magenta
|
||||
, 'enum' : undefined
|
||||
, 'export' : undefined
|
||||
, 'extends' : undefined
|
||||
|
||||
, 'finally' : colors.magenta
|
||||
, 'for' : colors.magenta
|
||||
, 'function' : colors.magenta
|
||||
|
||||
, 'if' : colors.magenta
|
||||
, 'implements' : undefined
|
||||
, 'import' : undefined
|
||||
, 'in' : colors.cyan
|
||||
, 'instanceof' : colors.cyan
|
||||
, 'let' : undefined
|
||||
, 'new' : colors.cyan
|
||||
, 'package' : undefined
|
||||
, 'private' : undefined
|
||||
, 'protected' : undefined
|
||||
, 'public' : undefined
|
||||
, 'return' : colors.magenta
|
||||
, 'static' : undefined
|
||||
, 'super' : undefined
|
||||
, 'switch' : colors.magenta
|
||||
|
||||
, 'this' : colors.red
|
||||
, 'throw' : colors.magenta
|
||||
, 'try' : colors.magenta
|
||||
, 'typeof' : colors.cyan
|
||||
|
||||
, 'var' : colors.magenta
|
||||
, 'void' : colors.magenta
|
||||
|
||||
, 'while' : colors.magenta
|
||||
, 'with' : colors.cyan
|
||||
, 'yield' : undefined
|
||||
, _default : colors.white
|
||||
}
|
||||
, 'Punctuator': {
|
||||
';': colors.white
|
||||
, '.': colors.white
|
||||
, ',': colors.white
|
||||
|
||||
, '{': colors.white
|
||||
, '}': colors.white
|
||||
, '(': colors.white
|
||||
, ')': colors.white
|
||||
, '[': colors.white
|
||||
, ']': colors.white
|
||||
|
||||
, '<': undefined
|
||||
, '>': undefined
|
||||
, '+': undefined
|
||||
, '-': undefined
|
||||
, '*': undefined
|
||||
, '%': undefined
|
||||
, '&': undefined
|
||||
, '|': colors.white
|
||||
, '^': undefined
|
||||
, '!': undefined
|
||||
, '~': undefined
|
||||
, '?': colors.white
|
||||
, ':': colors.white
|
||||
, '=': undefined
|
||||
|
||||
, '<=': undefined
|
||||
, '>=': undefined
|
||||
, '==': undefined
|
||||
, '!=': undefined
|
||||
, '++': undefined
|
||||
, '--': undefined
|
||||
, '<<': undefined
|
||||
, '>>': undefined
|
||||
, '&&': undefined
|
||||
, '||': undefined
|
||||
, '+=': undefined
|
||||
, '-=': undefined
|
||||
, '*=': undefined
|
||||
, '%=': undefined
|
||||
, '&=': undefined
|
||||
, '|=': undefined
|
||||
, '^=': undefined
|
||||
, '/=': undefined
|
||||
, '=>': undefined
|
||||
|
||||
, '===': undefined
|
||||
, '!==': undefined
|
||||
, '>>>': undefined
|
||||
, '<<=': undefined
|
||||
, '>>=': undefined
|
||||
, '...': undefined
|
||||
|
||||
, '>>>=': undefined
|
||||
|
||||
, _default: colors.cyan
|
||||
}
|
||||
|
||||
// line comment
|
||||
, Line: {
|
||||
_default: colors.brightBlack
|
||||
}
|
||||
|
||||
/* block comment */
|
||||
, Block: {
|
||||
_default: colors.brightBlack
|
||||
}
|
||||
|
||||
, _default: undefined
|
||||
};
|
||||
11
node_modules/cardinal/utl.js
generated
vendored
Normal file
11
node_modules/cardinal/utl.js
generated
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
var util = require('util');
|
||||
|
||||
module.exports.isPath = function (s) {
|
||||
return (/[\/\\]/).test(s);
|
||||
};
|
||||
|
||||
module.exports.inspect = function(obj, depth) {
|
||||
console.log(util.inspect(obj, false, depth || 5, true));
|
||||
};
|
||||
|
||||
|
||||
Loading…
Reference in a new issue