Skip to content

Commit

Permalink
Fancy colorful console output for build system
Browse files Browse the repository at this point in the history
  • Loading branch information
belyaev-mikhail committed Sep 2, 2021
1 parent feb6220 commit 13339cd
Show file tree
Hide file tree
Showing 3 changed files with 1,796 additions and 1,782 deletions.
6 changes: 4 additions & 2 deletions kotoed-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"@types/sockjs-client": "~1.0.30",
"@types/vertx3-eventbus-client": "~3.4.0",
"@types/webpack": "~3.0.4",
"ansi_up": "~5.0.1",
"awesome-typescript-loader": "~3.2.1",
"babel-core": "~6.25.0",
"babel-loader": "~7.1.1",
Expand Down Expand Up @@ -60,6 +61,7 @@
"@types/emoji-mart": "^2.8.1",
"@types/react-click-outside": "^3.0.2",
"@types/tinycolor2": "^1.4.0",
"ansi-to-html": "~0.7.1",
"axios": "~0.16.2",
"babel-polyfill": "~6.23.0",
"babel-preset-es2015": "~6.24.1",
Expand All @@ -79,6 +81,7 @@
"lodash": "~4.17.4",
"moment": "~2.18.1",
"mousetrap": "1.6.1",
"natsort": "^2.0.2",
"path-to-regexp": "^1.7.0",
"query-string": "~5.0.0",
"radium": "~0.19.1",
Expand All @@ -103,7 +106,6 @@
"tinycolor2": "^1.4.1",
"twemoji": "^11.0.1",
"typescript-fsa": "~2.4.0",
"vertx3-eventbus-client": "~3.4.2",
"natsort": "^2.0.2"
"vertx3-eventbus-client": "~3.4.2"
}
}
11 changes: 10 additions & 1 deletion kotoed-js/src/main/ts/buildSystem/status.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {render} from "react-dom";
import * as React from "react";
import * as AnsiUp from 'ansi_up';
import {Panel, PanelGroup, Row} from 'react-bootstrap';
import {Kotoed} from "../util/kotoed-api";
import {WithId} from "../data/common";
Expand All @@ -8,6 +9,11 @@ import SpinnerWithVeil from "../views/components/SpinnerWithVeil";
import * as moment from "../code/components/CommentComponent";
import {poll, SimplePollingStrategy} from "../util/poll";

const ansiToHtml = (() => {
const ansiUpObject = new AnsiUp.default()
return ansiUpObject.ansi_to_html.bind(ansiUpObject) as (txt:string) => string
})()

type BuildStatusState = { loading: true }
| { loading: false, status: BuildStatus }

Expand Down Expand Up @@ -51,7 +57,10 @@ class BuildStatusView extends React.Component<WithId, BuildStatusState> {
collapsible defaultExpanded={false}
header={<pre>{v.commandLine}</pre>}
bsStyle={this.bsClassFor(v)}
> { <pre>{v.cout}{'\n'}{v.cerr}</pre> }
> { <pre>
<div dangerouslySetInnerHTML={{__html: ansiToHtml(v.cout)}} />
<div dangerouslySetInnerHTML={{__html: ansiToHtml(v.cerr)}} />
</pre> }
</Panel>
)
}
Expand Down
Loading

0 comments on commit 13339cd

Please sign in to comment.