-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 66de0d7
Showing
21 changed files
with
3,395 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
root = true | ||
|
||
[*] | ||
end_of_line = lf | ||
insert_final_newline = true | ||
|
||
[*.{js,json}] | ||
charset = utf-8 | ||
indent_style = space | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"extends": [ | ||
"config:best-practices", | ||
":automergeBranch", | ||
":automergeMinor", | ||
":maintainLockFilesWeekly", | ||
":semanticCommits" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
name: checks | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- renovate/** | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
lint: | ||
if: github.event_name == 'push' || (github.event_name == 'pull_request' && !startsWith(github.head_ref, 'renovate/')) | ||
name: Lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 | ||
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4 | ||
with: | ||
node-version: lts/* | ||
- run: npm install | ||
- run: npm run check | ||
- run: npm run lint | ||
|
||
test-types: | ||
if: github.event_name == 'push' || (github.event_name == 'pull_request' && !startsWith(github.head_ref, 'renovate/')) | ||
name: Test Types | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 | ||
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4 | ||
with: | ||
node-version: lts/* | ||
- run: npm install | ||
- run: npm run test:types -- --target 4.8,5.0,latest | ||
|
||
test-node: | ||
if: github.event_name == 'push' || (github.event_name == 'pull_request' && !startsWith(github.head_ref, 'renovate/')) | ||
name: Test on Node.js v${{ matrix.node-version }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
node-version: [16.x, 18.x, 20.x, 21.x] | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- run: npm install | ||
- run: npm run test | ||
env: | ||
FORCE_COLOR: true | ||
|
||
test-os: | ||
if: github.event_name == 'push' || (github.event_name == 'pull_request' && !startsWith(github.head_ref, 'renovate/')) | ||
name: Test on ${{ matrix.os }} using Node.js LTS | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ubuntu-latest, windows-latest, macOS-latest] | ||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 | ||
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4 | ||
with: | ||
node-version: lts/* | ||
- run: npm install | ||
- run: npm run test | ||
env: | ||
FORCE_COLOR: true | ||
|
||
test-coverage: | ||
if: github.event_name == 'push' || (github.event_name == 'pull_request' && !startsWith(github.head_ref, 'renovate/')) | ||
name: Collect Test Coverage | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 | ||
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4 | ||
with: | ||
node-version: lts/* | ||
- run: npm install | ||
- run: npm run test:coverage | ||
env: | ||
FORCE_COLOR: true | ||
- uses: codacy/codacy-coverage-reporter-action@89d6c85cfafaec52c72b6c5e8b2878d33104c699 # v1 | ||
with: | ||
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} | ||
coverage-reports: ./coverage/lcov.info |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
coverage | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"editor.codeActionsOnSave": { | ||
"source.fixAll": "explicit" | ||
}, | ||
"editor.formatOnSave": true, | ||
"editor.rulers": [80, 120], | ||
"eslint.options": { "overrideConfigFile": "./eslint.config.json" }, | ||
"files.associations": { | ||
"dprint.json": "jsonc", | ||
"eslint.config.json": "jsonc" | ||
}, | ||
"typescript.tsdk": "./node_modules/typescript/lib" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Changelog | ||
|
||
## [1.0.0] - 2024-02-19 | ||
|
||
_First release._ | ||
|
||
[1.0.0]: https://github.com/mrazauskas/pretty-ansi/releases/tag/v1.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 Tom Mrazauskas | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# pretty-ansi | ||
|
||
[![version][version-badge]][version-url] | ||
[![license][license-badge]][license-url] | ||
[![packagephobia][packagephobia-badge]][packagephobia-url] | ||
[![coverage][coverage-badge]][coverage-url] | ||
|
||
Convert ANSI escape sequences to human readable text. | ||
|
||
--- | ||
|
||
This utility converts [ANSI escape sequences](https://en.wikipedia.org/wiki/ANSI_escape_code) to human readable text. It supports color, style and cursor control escapes and works with vanilla sequences as well as the output from libraries like `chalk`, `colors`, `ansi-escapes`, `ansi-styles` or `terminal-kit`. | ||
|
||
## Install | ||
|
||
```bash | ||
npm add -D pretty-ansi | ||
``` | ||
|
||
## Usage | ||
|
||
For example, it can be useful to test the output of a command line tool: | ||
|
||
```js | ||
import { expect } from "chai"; | ||
import { test } from "mocha"; | ||
|
||
import prettyAnsi from "pretty-ansi"; | ||
|
||
test("command output", () => { | ||
const commandOutput = "\u001b[3;32mSuccess!\u001b[0m"; | ||
|
||
expect(prettyAnsi(commandOutput)).to.equal("<italic, green>Success!</>"); | ||
}); | ||
``` | ||
|
||
## Notes | ||
|
||
Currently only 16 colors are all supported. | ||
|
||
Keep in mind that the escape sequences are not validated. Unrecognized sequence will print as `<ESC>[a1b2c3`, or as `<?>` in case this is a color or style sequence. | ||
|
||
## Related | ||
|
||
- [`jest-serializer-ansi-escapes`](https://github.com/mrazauskas/jest-serializer-ansi-escapes) - Jest snapshot serializer for ANSI escape sequences. | ||
|
||
## License | ||
|
||
[MIT][license-url] | ||
|
||
[version-badge]: https://badgen.net/npm/v/pretty-ansi | ||
[version-url]: https://npmjs.com/package/pretty-ansi | ||
[license-badge]: https://badgen.net/github/license/mrazauskas/pretty-ansi | ||
[license-url]: https://github.com/mrazauskas/pretty-ansi/blob/main/LICENSE.md | ||
[packagephobia-badge]: https://badgen.net/packagephobia/install/pretty-ansi | ||
[packagephobia-url]: https://packagephobia.com/result?p=pretty-ansi | ||
[coverage-badge]: https://badgen.net/codacy/coverage/3a26cda9352643b589953c686f921c40 | ||
[coverage-url]: https://app.codacy.com/gh/mrazauskas/pretty-ansi/coverage/dashboard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"all": true, | ||
"include": ["**/*.js"], | ||
"reporter": ["lcovonly", "text"], | ||
"tempDirectory": "./coverage/temp" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"typescript": { | ||
"quoteStyle": "preferDouble", | ||
|
||
"module.sortImportDeclarations": "maintain", | ||
"module.sortExportDeclarations": "maintain" | ||
}, | ||
"excludes": [ | ||
"**/coverage/", | ||
"**/node_modules/" | ||
], | ||
"plugins": [ | ||
"https://plugins.dprint.dev/typescript-0.89.1.wasm", | ||
"https://plugins.dprint.dev/json-0.19.1.wasm", | ||
"https://plugins.dprint.dev/markdown-0.16.3.wasm" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"env": { | ||
"es2021": true, | ||
"node": true | ||
}, | ||
"extends": [ | ||
"eslint:recommended" | ||
], | ||
"parserOptions": { | ||
"ecmaVersion": "latest", | ||
"sourceType": "module" | ||
}, | ||
"rules": { | ||
"no-control-regex": "off", | ||
"no-implicit-coercion": "error", | ||
"no-negated-condition": "error", | ||
"no-nested-ternary": "error", | ||
"no-useless-concat": "error", | ||
"prefer-template": "error", | ||
"sort-keys": "error" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { expect } from "chai"; | ||
import { test } from "mocha"; | ||
|
||
import prettyAnsi from "pretty-ansi"; | ||
|
||
test("command output", () => { | ||
const commandOutput = "\u001b[3;32mSuccess!\u001b[0m"; | ||
|
||
expect(prettyAnsi(commandOutput)).to.equal("<italic, green>Success!</>"); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/** | ||
* Converts [ANSI escape sequences](https://en.wikipedia.org/wiki/ANSI_escape_code) | ||
* into human readable text. | ||
*/ | ||
declare function prettyAnsi(text: string): string; | ||
|
||
export default prettyAnsi; |
Oops, something went wrong.