mirror of
https://github.com/astefanutti/decktape.git
synced 2024-12-12 13:49:13 +03:00
e2bb2c93c3
Activates CLI string styling with Chalk except on Windows OS. Adds the libs directory to the require paths for seamless referencing of require libraries.
51 lines
901 B
JavaScript
51 lines
901 B
JavaScript
'use strict';
|
|
var argv = process.argv;
|
|
|
|
var terminator = argv.indexOf('--');
|
|
var hasFlag = function (flag) {
|
|
flag = '--' + flag;
|
|
var pos = argv.indexOf(flag);
|
|
return pos !== -1 && (terminator !== -1 ? pos < terminator : true);
|
|
};
|
|
|
|
module.exports = (function () {
|
|
if ('FORCE_COLOR' in process.env) {
|
|
return true;
|
|
}
|
|
|
|
if (hasFlag('no-color') ||
|
|
hasFlag('no-colors') ||
|
|
hasFlag('color=false')) {
|
|
return false;
|
|
}
|
|
|
|
if (hasFlag('color') ||
|
|
hasFlag('colors') ||
|
|
hasFlag('color=true') ||
|
|
hasFlag('color=always')) {
|
|
return true;
|
|
}
|
|
|
|
if (process.stdout && !process.stdout.isTTY) {
|
|
return false;
|
|
}
|
|
|
|
if (process.platform === 'win32') {
|
|
return true;
|
|
}
|
|
|
|
if ('COLORTERM' in process.env) {
|
|
return true;
|
|
}
|
|
|
|
if (process.env.TERM === 'dumb') {
|
|
return false;
|
|
}
|
|
|
|
if (/^screen|^xterm|^vt100|color|ansi|cygwin|linux/i.test(process.env.TERM)) {
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
})();
|