Skip to content

Commit

Permalink
added ansi-regex.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
amorey committed May 10, 2024
1 parent 2d9dae7 commit 142c32c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/ansi-regex.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Embedding this here because the ansi-regex import is
// triggering an jspm error (https://github.com/kubetail-org/fancy-ansi/issues/16)
// https://github.com/chalk/ansi-regex/blob/main/index.js
export default function ansiRegex({onlyFirst = false} = {}) {

Check failure on line 4 in src/ansi-regex.ts

View workflow job for this annotation

GitHub Actions / lint

A space is required after '{'

Check failure on line 4 in src/ansi-regex.ts

View workflow job for this annotation

GitHub Actions / lint

A space is required before '}'
const pattern = [
'[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)',
'(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))'

Check failure on line 7 in src/ansi-regex.ts

View workflow job for this annotation

GitHub Actions / lint

Missing trailing comma
].join('|');

return new RegExp(pattern, onlyFirst ? undefined : 'g');
}

0 comments on commit 142c32c

Please sign in to comment.