forked from loopj/commonjs-ansi-color
-
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
1 parent
ee861d0
commit d68cc7d
Showing
10 changed files
with
365 additions
and
112 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,6 @@ | ||
{ | ||
"$schema": "https://docs.renovatebot.com/renovate-schema.json", | ||
"extends": [ | ||
"local>myrotvorets/.github:renovate-config" | ||
] | ||
} |
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,39 @@ | ||
name: Build and Test | ||
|
||
on: | ||
push: | ||
branches: | ||
- '**' | ||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: none | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
if: ${{ !contains(github.event.head_commit.message, '[ci skip]') || github.event_name == 'workflow_dispatch' }} | ||
strategy: | ||
matrix: | ||
node: | ||
- { name: Current, version: current } | ||
- { name: LTS, version: lts/* } | ||
name: Build and test (Node ${{ matrix.node.name }}) | ||
permissions: | ||
contents: read | ||
steps: | ||
- name: Harden Runner | ||
uses: step-security/harden-runner@8ca2b8b2ece13480cda6dacd3511b49857a23c09 # v2.5.1 | ||
with: | ||
disable-sudo: true | ||
egress-policy: block | ||
allowed-endpoints: > | ||
api.github.com:443 | ||
github.com:443 | ||
nodejs.org:443 | ||
registry.npmjs.org:443 | ||
- name: Build and test | ||
uses: myrotvorets/composite-actions/build-test-nodejs@master | ||
with: | ||
node-version: ${{ matrix.node.version }} |
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,53 @@ | ||
name: CodeQL | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- master | ||
schedule: | ||
- cron: "57 17 * * 4" | ||
|
||
jobs: | ||
analyze: | ||
name: Analyze | ||
runs-on: ubuntu-latest | ||
permissions: | ||
actions: read | ||
contents: read | ||
security-events: write | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
language: | ||
- javascript | ||
steps: | ||
- name: Harden Runner | ||
uses: step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.6.0 | ||
with: | ||
disable-sudo: true | ||
egress-policy: block | ||
allowed-endpoints: > | ||
api.github.com:443 | ||
github.com:443 | ||
uploads.github.com:443 | ||
objects.githubusercontent.com:443 | ||
- name: Checkout | ||
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 | ||
|
||
- name: Initialize CodeQL | ||
uses: github/codeql-action/init@ddccb873888234080b77e9bc2d4764d5ccaaccf9 # v2.21.9 | ||
with: | ||
languages: ${{ matrix.language }} | ||
queries: +security-and-quality | ||
|
||
- name: Autobuild | ||
uses: github/codeql-action/autobuild@ddccb873888234080b77e9bc2d4764d5ccaaccf9 # v2.21.9 | ||
|
||
- name: Perform CodeQL Analysis | ||
uses: github/codeql-action/analyze@ddccb873888234080b77e9bc2d4764d5ccaaccf9 # v2.21.9 | ||
with: | ||
category: "/language:${{ matrix.language }}" |
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,31 @@ | ||
name: Package Audit | ||
|
||
on: | ||
push: | ||
branches: | ||
- '**' | ||
paths: | ||
- package.json | ||
- package-lock.json | ||
- .github/workflows/package-audit.yml | ||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
audit-npm: | ||
name: NPM Audit | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Harden Runner | ||
uses: step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.6.0 | ||
with: | ||
disable-sudo: true | ||
allowed-endpoints: | ||
api.github.com:443 | ||
github.com:443 | ||
registry.npmjs.org:443 | ||
|
||
- name: Audit with NPM | ||
uses: myrotvorets/composite-actions/node-package-audit@master |
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
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,19 @@ | ||
/** | ||
* @param {string} message | ||
* @param {string} color | ||
* @return {void} | ||
*/ | ||
export function log(message: string, color: string): void; | ||
/** | ||
* @param {string} str | ||
* @param {string} color | ||
* @return {string} | ||
*/ | ||
export function set(str: string, color: string): string; | ||
/** | ||
* @param {string} full_text | ||
* @param {string} search_regex | ||
* @param {string} color | ||
* @return {string} | ||
*/ | ||
export function replace(full_text: string, search_regex: string, color: string): string; |
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 |
---|---|---|
@@ -1,62 +1,73 @@ | ||
(function() { | ||
// ANSI color code outputs for strings | ||
|
||
var ANSI_CODES = { | ||
"off": 0, | ||
"bold": 1, | ||
"italic": 3, | ||
"underline": 4, | ||
"blink": 5, | ||
"inverse": 7, | ||
"hidden": 8, | ||
"black": 30, | ||
"red": 31, | ||
"green": 32, | ||
"yellow": 33, | ||
"blue": 34, | ||
"magenta": 35, | ||
"cyan": 36, | ||
"white": 37, | ||
"black_bg": 40, | ||
"red_bg": 41, | ||
"green_bg": 42, | ||
"yellow_bg": 43, | ||
"blue_bg": 44, | ||
"magenta_bg": 45, | ||
"cyan_bg": 46, | ||
"white_bg": 47 | ||
const ANSI_CODES = { | ||
off: 0, | ||
bold: 1, | ||
italic: 3, | ||
underline: 4, | ||
blink: 5, | ||
inverse: 7, | ||
hidden: 8, | ||
black: 30, | ||
red: 31, | ||
green: 32, | ||
yellow: 33, | ||
blue: 34, | ||
magenta: 35, | ||
cyan: 36, | ||
white: 37, | ||
black_bg: 40, | ||
red_bg: 41, | ||
green_bg: 42, | ||
yellow_bg: 43, | ||
blue_bg: 44, | ||
magenta_bg: 45, | ||
cyan_bg: 46, | ||
white_bg: 47 | ||
}; | ||
|
||
function setColor(str,color) { | ||
if(!color) return str; | ||
var color_attrs = color.split("+"); | ||
var ansi_str = ""; | ||
for(var i=0, attr; attr = color_attrs[i]; i++) { | ||
ansi_str += "\033[" + ANSI_CODES[attr] + "m"; | ||
/** | ||
* @param {string} str | ||
* @param {string} color | ||
* @return {string} | ||
*/ | ||
function set(str, color) { | ||
if (color) { | ||
const attributes = color.split('+'); | ||
let ansiStr = ""; | ||
for (const attr of attributes) { | ||
ansiStr += `\u001B[${ANSI_CODES[attr]}m`; | ||
} | ||
|
||
ansiStr += str + `\u001B[${ANSI_CODES["off"]}m`; | ||
return ansiStr; | ||
} | ||
ansi_str += str + "\033[" + ANSI_CODES["off"] + "m"; | ||
return ansi_str; | ||
|
||
return str; | ||
} | ||
|
||
function logMessage(message,color) { | ||
console.log(setColor(message,color)); | ||
/** | ||
* @param {string} message | ||
* @param {string} color | ||
* @return {void} | ||
*/ | ||
function log(message, color) { | ||
console.log(set(message,color)); | ||
} | ||
|
||
/** | ||
* @param {string} full_text | ||
* @param {string} search_regex | ||
* @param {string} color | ||
* @return {string} | ||
*/ | ||
function replace(full_text, search_regex, color) { | ||
try { | ||
var regex = new RegExp('(' + search_regex + ')', 'ig'); | ||
var new_text = full_text.replace(regex, setColor('$1', color)); | ||
return new_text; | ||
} catch (e) { | ||
return full_text; | ||
const regex = new RegExp('(' + search_regex + ')', 'ig'); | ||
return full_text.replace(regex, set('$1', color)); | ||
} catch { | ||
return full_text; | ||
} | ||
} | ||
|
||
if (typeof exports !== "undefined") { | ||
exports.log = logMessage; | ||
exports.set = setColor; | ||
exports.replace = replace; | ||
} else if (typeof define !== "undefined") { | ||
define([], function() { return { set: setColor, log: logMessage }; }); | ||
} | ||
}()); | ||
exports.log = log; | ||
exports.set = set; | ||
exports.replace = replace; |
Oops, something went wrong.