Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function TTYStream(fd) {
// Could use: if (!require('tty').ReadStream)
if (version[0] === 0 && version[1] < 7) {
return new net.Socket(fd);
}
if (version[0] === 0 && version[1] < 12) {
return new tty.ReadStream(fd);
}
return new Socket(fd);
}
var tty = require('tty');
var chalk = require('chalk');
var enabled = process.env.COLOR || (!process.env.NOCOLOR && tty.isatty(1) && tty.isatty(2));
module.exports = new chalk.constructor({ enabled: enabled });
internals.color = function (name, code, forceColor) {
if ((Tty.isatty(1) && Tty.isatty(2)) || forceColor) {
var color = '\u001b[' + code + 'm';
return function (text) { return color + text + '\u001b[0m'; };
}
return function (text) { return text; };
};
function readCachedConfig(cwd) {
if (cachedConfigs[cwd]) { return cachedConfigs[cwd]; }
var config = cachedConfigs[cwd] = normalise(rc('nodesvm', defaults, cwd));
if (!_o.has(config, 'interactive')) {
config.interactive = (process.bin === 'node-svm' && tty.isatty(1) && !process.env.CI);
}
return config;
}
function resetCache () {
function setRaw(mode) {
return process.stdin.setRawMode ?
process.stdin.setRawMode(mode) : tty.setRawMode(mode);
}
function setRawMode(val) {
if (process.stdin.setRawMode)
process.stdin.setRawMode(val);
else
require('tty').setRawMode(val);
}
function setRawMode(mode) {
if (process.stdin.setRawMode) {
process.stdin.setRawMode(mode);
}
else if (process.stderr.isTTY) {
tty.setRawMode(mode);
}
}
if (hideInput) setRawMode(true);
function createWritableStdioStream(fd) {
var tty = require('tty');
var stream = new tty.WriteStream(fd);
stream._type = 'tty';
if (stream._handle && stream._handle.unref) {
stream._handle.unref();
}
stream.fd = fd;
stream._isStdio = true;
return stream;
}
get: function() {
if (!this._stdout) {
if ( this.terminal ) {
this._stdout = new tty.WriteStream( this.terminal );
} else {
this._stdout = new streams.OutputStream( System.out );
}
this._stdout._start();
}
return this._stdout;
}
});
write(output, json = false) {
if (this.outputPath) {
fs.writeFileSync(this.outputPath, output);
} else if (isatty(process.stdout.fd) && json) {
const highlighted = highlight(output, { json: true, theme });
process.stdout.write(highlighted);
} else {
process.stdout.write(output);
}
}
}