Skip to content

letsenhance/remove-ansi-colors

 
 

Repository files navigation

paint

remove-ansi-colors

Tests Issues Dependabot License

A GitHub action for removing ANSI color escape sequences from arbitrary strings.

Prerequisites

This action has a few dependencies that are generally satisfied by most GitHub-hosted runners (macos-* and ubuntu-* environment variants):

Usage

Add a suitable uses step to your GitHub workflow with a value for the colored step input (i.e. an output from a previous step that includes ANSI color escape sequences) and use the uncolored output in subsequent steps:

jobs:
  remove-ansi-colors:
    runs-on: ubuntu-latest
    steps:
      - name: A step that generates output with ANSI color escape sequences
        id: generate-colored-output
        run: |
          colored=$(printf '\e[0;31mCOLORED\e[0m')
          echo "::set-output name=colored::$colored"
      - name: Remove ANSI color escape sequences
        uses: marcransome/remove-ansi-colors@v1
        id: remove-ansi-colors
        with:
          colored: ${{ steps.generate-colored-output.outputs.colored }}
      - name: Use uncolored output
        run: echo "${{ steps.remove-ansi-colors.outputs.uncolored }}"

Inputs

  • colored - A string containing ANSI color escape sequences.

Outputs

  • uncolored - The colored input string with ANSI color escape sequences removed.

Action versions

Use one of the following patterns when specifying the version reference for this action in your workflow (i.e. the {ref} value in uses: marcransome/remove-ansi-colors@{ref}):

Pattern Example Description
vX v1 the latest v1.* release including non-breaking changes and bug fixes
vX.Y v1.1 the latest v1.1.* release including bug fixes
vX.Y.Z v1.1.0 the v1.1.0 release only

The recommended pattern is vX (e.g. v1). This will ensure that the version of the action used in your workflow includes the latest non-breaking changes and bug fixes, and guarantees compatibility with previous versions of that major release number.

Using a main branch reference in your workflow is not recommended as this branch may include breaking changes intended for the next major release.

Acknowledgements

License

remove-ansi-colors is provided under the terms of the MIT License.

Contact

Email me at marc.ransome@fidgetbox.co.uk or create an issue.

About

A GitHub action for removing ANSI color escape sequences from arbitrary strings.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published