Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/testing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: node tests/test.js
- run: FORCE_COLOR=1 node tests/test.js
legacy:
name: Node v${{ matrix.node-version }} (Legacy)
runs-on: ubuntu-latest
Expand All @@ -40,4 +40,4 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: node tests/test.js
- run: FORCE_COLOR=1 node tests/test.js
2 changes: 1 addition & 1 deletion picocolors.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
let p = process || {}, argv = p.argv || [], env = p.env || {}
let isColorSupported =
!(!!env.NO_COLOR || argv.includes("--no-color")) &&
(!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || ((p.stdout || {}).isTTY && env.TERM !== "dumb") || !!env.CI)
(!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || !!((p.stdout || {}).isTTY && env.TERM !== "dumb"))

let formatter = (open, close, replace = open) =>
input => {
Expand Down
6 changes: 3 additions & 3 deletions tests/environments.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ let CI = process.env.CI

test("ci server", () => {
let pc = initModuleEnv({ env: { TERM: "dumb", CI: "1" } })
assert.equal(pc.isColorSupported, true)
assert.equal(pc.red("text"), pc.createColors(true).red("text"))
assert.equal(pc.isColorSupported, false)
assert.equal(pc.red("text"), pc.createColors(false).red("text"))
})

test("arg --color", () => {
Expand All @@ -25,7 +25,7 @@ test("env NO_COLOR", () => {
})

test("env NO_COLOR empty", () => {
let pc = initModuleEnv({ env: { NO_COLOR: "", CI } })
let pc = initModuleEnv({ env: { FORCE_COLOR: "1", NO_COLOR: "" } })
assert.equal(pc.isColorSupported, true)
assert.equal(pc.red("text"), pc.createColors(true).red("text"))
})
Expand Down