-
-
Notifications
You must be signed in to change notification settings - Fork 638
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: improve parseBody function and docs (#2628)
* refactor: improve parsebody function and docs * refactor: Improve test and function from color function * chore: remove comments * chore: use the previous function * refactor: remove the if operator
- Loading branch information
Showing
6 changed files
with
79 additions
and
100 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
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,12 +1,14 @@ | ||
export function getColorEnabled() { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
const { process, Deno } = globalThis as any | ||
|
||
const isNoColor = | ||
typeof process !== 'undefined' | ||
? // eslint-disable-next-line no-unsafe-optional-chaining | ||
'NO_COLOR' in process?.env | ||
: typeof Deno?.noColor === 'boolean' | ||
? (Deno.noColor as boolean) | ||
: false | ||
|
||
return !isNoColor | ||
} |
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
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,18 +1,21 @@ | ||
import { getColorEnabled } from './color' | ||
|
||
describe('getColorEnabled()', () => { | ||
it('getColorEnabled() is true', async () => { | ||
describe('getColorEnabled() - With colors enabled', () => { | ||
it('should return true', async () => { | ||
expect(getColorEnabled()).toBe(true) | ||
}) | ||
}) | ||
describe('getColorEnabled() in NO_COLOR', () => { | ||
|
||
describe('getColorEnabled() - With NO_COLOR environment variable set', () => { | ||
beforeAll(() => { | ||
vi.stubEnv('NO_COLOR', '1') | ||
}) | ||
|
||
afterAll(() => { | ||
vi.unstubAllEnvs() | ||
}) | ||
it('getColorEnabled() is false', async () => { | ||
|
||
it('should return false', async () => { | ||
expect(getColorEnabled()).toBe(false) | ||
}) | ||
}) |
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,12 +1,14 @@ | ||
export function getColorEnabled() { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
const { process, Deno } = globalThis as any | ||
|
||
const isNoColor = | ||
typeof process !== 'undefined' | ||
? // eslint-disable-next-line no-unsafe-optional-chaining | ||
'NO_COLOR' in process?.env | ||
: typeof Deno?.noColor === 'boolean' | ||
? (Deno.noColor as boolean) | ||
: false | ||
|
||
return !isNoColor | ||
} |