forked from orbit-oss/chalk
parent
2a678789b1
commit
6a14c58e54
2 changed files with 27 additions and 11 deletions
|
|
@ -1,15 +1,15 @@
|
|||
'use strict';
|
||||
const resolveFrom = require('resolve-from');
|
||||
|
||||
module.exports = dir => {
|
||||
require.cache[resolveFrom(dir, 'supports-color')] = {
|
||||
exports: {
|
||||
stdout: {
|
||||
level: 3,
|
||||
hasBasic: true,
|
||||
has256: true,
|
||||
has16m: true
|
||||
}
|
||||
}
|
||||
};
|
||||
const DEFAULT = {
|
||||
stdout: {
|
||||
level: 3,
|
||||
hasBasic: true,
|
||||
has256: true,
|
||||
has16m: true
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = (dir, override) => {
|
||||
require.cache[resolveFrom(dir, 'supports-color')] = {exports: override || DEFAULT};
|
||||
};
|
||||
|
|
|
|||
16
test/no-color-support.js
Normal file
16
test/no-color-support.js
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import test from 'ava';
|
||||
|
||||
// Spoof supports-color
|
||||
require('./_supports-color')(__dirname, {
|
||||
level: 0,
|
||||
hasBasic: false,
|
||||
has256: false,
|
||||
has16m: false
|
||||
});
|
||||
|
||||
const chalk = require('..');
|
||||
|
||||
test.failing('colors can be forced by using chalk.enabled', t => {
|
||||
chalk.enabled = true;
|
||||
t.is(chalk.green('hello'), '\u001B[32mhello\u001B[39m');
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue