Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove simple dependencies #412

Merged
merged 6 commits into from
May 27, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions package.json
Expand Up @@ -67,8 +67,6 @@
"dependencies": {
"cli-truncate": "^2.1.0",
"colorette": "^1.2.2",
"figures": "^3.2.0",
"indent-string": "^4.0.0",
"log-update": "^4.0.0",
"p-map": "^4.0.0",
"rxjs": "^6.6.7",
Expand Down
10 changes: 5 additions & 5 deletions src/renderer/default.renderer.ts
@@ -1,6 +1,4 @@
import * as cliTruncate from 'cli-truncate'
import * as figures from 'figures'
import * as indentString from 'indent-string'
import * as logUpdate from 'log-update'
import { EOL } from 'os'
import * as cliWrap from 'wrap-ansi'
Expand All @@ -9,6 +7,8 @@ import { ListrContext } from '@interfaces/listr.interface'
import { ListrRenderer } from '@interfaces/renderer.interface'
import { Task } from '@lib/task'
import colorette from '@utils/colorette'
import { figures } from '@utils/figures'
import { indentString } from '@utils/indent-string'
import { isUnicodeSupported } from '@utils/is-unicode-supported'
import { parseTaskTime } from '@utils/parse-time'

Expand Down Expand Up @@ -152,7 +152,7 @@ export class DefaultRenderer implements ListrRenderer {
private bottomBar: { [uuid: string]: { data?: string[], items?: number } } = {}
private promptBar: string
private readonly spinner: string[] = !isUnicodeSupported() ? [ '-', '\\', '|', '/' ] : [ '⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏' ]
private readonly figures = !isUnicodeSupported() ? figures : figures.main
private readonly figures = figures
private spinnerPosition = 0

constructor (public tasks: Task<any, typeof DefaultRenderer>[], public options: typeof DefaultRenderer['rendererOptions'], public renderHook$?: Task<any, any>['renderHook$']) {
Expand Down Expand Up @@ -302,7 +302,7 @@ export class DefaultRenderer implements ListrRenderer {
}
} else {
// some sibling task but self has failed and this has stopped
output = [ ...output, this.formatString(task.title, colorette.red(figures.main.squareSmallFilled), level) ]
output = [ ...output, this.formatString(task.title, colorette.red('◼'), level) ]
}
}

Expand Down Expand Up @@ -498,7 +498,7 @@ export class DefaultRenderer implements ListrRenderer {
}

private indentMultilineOutput (str: string, i: number): string {
return i > 0 ? indentString(str.trim(), 2, { includeEmptyLines: false }) : str.trim()
return i > 0 ? indentString(str.trim(), 2) : str.trim()
}

// eslint-disable-next-line complexity
Expand Down
26 changes: 26 additions & 0 deletions src/utils/figures.ts
@@ -0,0 +1,26 @@
import { isUnicodeSupported } from './is-unicode-supported'

const FIGURES_MAIN = {
warning: '⚠',
cross: '✖',
arrowDown: '↓',
tick: '✔',
arrowRight: '→',
pointer: '❯',
checkboxOn: '☒',
arrowLeft: '←',
squareSmallFilled: '◼',
pointerSmall: '›'
}

const FIGURES_FALLBACK = {
...FIGURES_MAIN,
warning: '‼',
cross: '×',
tick: '√',
pointer: '>',
checkboxOn: '[×]',
squareSmallFilled: '■'
}

export const figures = isUnicodeSupported ? FIGURES_MAIN : FIGURES_FALLBACK
3 changes: 3 additions & 0 deletions src/utils/indent-string.ts
@@ -0,0 +1,3 @@
export function indentString (string: string, count: number): string {
return string.replace(/^(?!\s*$)/gm, ' '.repeat(count))
}
ai marked this conversation as resolved.
Show resolved Hide resolved
6 changes: 2 additions & 4 deletions src/utils/logger.ts
@@ -1,7 +1,5 @@
/* eslint-disable no-console */
import * as figures from 'figures'

import { isUnicodeSupported } from './is-unicode-supported'
import { figures } from './figures'
import { LogLevels } from './logger.constants'
import { LoggerOptions } from './logger.interface'
import colorette from '@utils/colorette'
Expand All @@ -10,7 +8,7 @@ import colorette from '@utils/colorette'
* A internal logger for using in the verbose renderer mostly.
*/
export class Logger {
private readonly figures = !isUnicodeSupported() ? figures : figures.main
private readonly figures = figures

constructor (private options?: LoggerOptions) {}

Expand Down