-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fake
hasColors()
in worker processes
Fixes #2170.
- Loading branch information
1 parent
90acbb9
commit d399797
Showing
5 changed files
with
37 additions
and
5 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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
'use strict'; | ||
const tty = require('tty'); | ||
|
||
// Call original method to ensure the correct errors are thrown. | ||
const assertHasColorsArguments = count => { | ||
tty.WriteStream.prototype.hasColors(count); | ||
}; | ||
|
||
const makeHasColors = colorDepth => (count = 16, env) => { | ||
// `count` is optional too, so make sure it's not an env object. | ||
if (env === undefined && typeof count === 'object' && count !== null) { | ||
count = 16; | ||
} | ||
|
||
assertHasColorsArguments(count); | ||
return count <= 2 ** colorDepth; | ||
}; | ||
|
||
module.exports = makeHasColors; |
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