Skip to content

Commit

Permalink
Use cli-highlight to syntax highlight markdown output
Browse files Browse the repository at this point in the history
  • Loading branch information
Turbo87 committed Jun 16, 2018
1 parent e47f36c commit 547a6aa
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 2 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
},
"dependencies": {
"chalk": "^2.4.1",
"cli-highlight": "^2.0.0",
"execa": "^0.10.0",
"make-fetch-happen": "^4.0.1",
"normalize-git-url": "^3.0.2",
Expand Down
14 changes: 13 additions & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

const chalk = require("chalk");

import { highlight } from "cli-highlight";

import Changelog from "./changelog";
import ConfigurationError from "./configuration-error";

Expand Down Expand Up @@ -33,7 +35,17 @@ export async function run() {

try {
let result = await new Changelog().createMarkdown(options);
console.log(result);

let highlighted = highlight(result, {
language: "Markdown",
theme: {
section: chalk.bold,
string: chalk.hex("#0366d6"),
link: chalk.dim,
},
});

console.log(highlighted);
} catch (e) {
if (e instanceof ConfigurationError) {
console.log(chalk.red(e.message));
Expand Down
40 changes: 39 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ ansi-styles@^3.2.0, ansi-styles@^3.2.1:
dependencies:
color-convert "^1.9.0"

any-promise@^1.0.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/any-promise/-/any-promise-1.3.0.tgz#abc6afeedcea52e809cdc0376aed3ce39635d17f"

anymatch@^1.3.0:
version "1.3.2"
resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-1.3.2.tgz#553dcb8f91e3c889845dfdba34c77721b90b9d7a"
Expand Down Expand Up @@ -758,6 +762,16 @@ class-utils@^0.3.5:
isobject "^3.0.0"
static-extend "^0.1.1"

cli-highlight@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/cli-highlight/-/cli-highlight-2.0.0.tgz#e4ae60d46fd6a88e7d478499309b6618547991f0"
dependencies:
chalk "^2.3.0"
highlight.js "^9.6.0"
mz "^2.4.0"
parse5 "^4.0.0"
yargs "^11.0.0"

cliui@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/cliui/-/cliui-2.1.0.tgz#4b475760ff80264c762c3a1719032e91c7fea0d1"
Expand Down Expand Up @@ -1655,6 +1669,10 @@ has@^1.0.1:
dependencies:
function-bind "^1.0.2"

highlight.js@^9.6.0:
version "9.12.0"
resolved "https://registry.yarnpkg.com/highlight.js/-/highlight.js-9.12.0.tgz#e6d9dbe57cbefe60751f02af336195870c90c01e"

home-or-tmp@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/home-or-tmp/-/home-or-tmp-2.0.0.tgz#e36c3f2d2cae7d746a857e38d18d5f32a7882db8"
Expand Down Expand Up @@ -2873,6 +2891,14 @@ ms@2.0.0, ms@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8"

mz@^2.4.0:
version "2.7.0"
resolved "https://registry.yarnpkg.com/mz/-/mz-2.7.0.tgz#95008057a56cafadc2bc63dde7f9ff6955948e32"
dependencies:
any-promise "^1.0.0"
object-assign "^4.0.1"
thenify-all "^1.0.0"

nan@^2.9.2:
version "2.10.0"
resolved "https://registry.yarnpkg.com/nan/-/nan-2.10.0.tgz#96d0cd610ebd58d4b4de9cc0c6828cda99c7548f"
Expand Down Expand Up @@ -3163,7 +3189,7 @@ parse-json@^4.0.0:
error-ex "^1.3.1"
json-parse-better-errors "^1.0.1"

parse5@4.0.0:
parse5@4.0.0, parse5@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/parse5/-/parse5-4.0.0.tgz#6d78656e3da8d78b4ec0b906f7c08ef1dfe3f608"

Expand Down Expand Up @@ -3959,6 +3985,18 @@ test-exclude@^4.2.1:
read-pkg-up "^1.0.1"
require-main-filename "^1.0.1"

thenify-all@^1.0.0:
version "1.6.0"
resolved "https://registry.yarnpkg.com/thenify-all/-/thenify-all-1.6.0.tgz#1a1918d402d8fc3f98fbf234db0bcc8cc10e9726"
dependencies:
thenify ">= 3.1.0 < 4"

"thenify@>= 3.1.0 < 4":
version "3.3.0"
resolved "https://registry.yarnpkg.com/thenify/-/thenify-3.3.0.tgz#e69e38a1babe969b0108207978b9f62b88604839"
dependencies:
any-promise "^1.0.0"

throat@^4.0.0, throat@^4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/throat/-/throat-4.1.0.tgz#89037cbc92c56ab18926e6ba4cbb200e15672a6a"
Expand Down

0 comments on commit 547a6aa

Please sign in to comment.