Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.paths = this.settings.env.PATH.split(':');
this.home = this.settings.env.HOME;
this.cwd = this.home;
this.completer = new Completer(this);
this.executor = new Executor(this);
const input = process.stdin;
const output = process.stdout;
const terminal = true;
const completer = this.completer.complete.bind(this.completer);
this.rl = readline.createInterface({input, output, terminal, completer});
this.setPrompt();
this._readHistory();
readline.emitKeypressEvents(process.stdin, this.rl);
if (process.stdin.isTTY) {
process.stdin.setRawMode(true);
}
this._lineCallbacks = [];
this._attachHandlers();
this._fireInitialized();
});
}
constructor(opts={}) {
super();
this.firstRender = true;
this.in = opts.stdin || process.stdin;
this.out = opts.stdout || process.stdout;
this.onRender = (opts.onRender || (() => void 0)).bind(this);
const rl = readline.createInterface(this.in);
readline.emitKeypressEvents(this.in, rl);
if (this.in.isTTY) this.in.setRawMode(true);
const isSelect = [ 'SelectPrompt', 'MultiselectPrompt' ].indexOf(this.constructor.name) > -1;
const keypress = (str, key) => {
let a = action(key, isSelect);
if (a === false) {
this._ && this._(str, key);
} else if (typeof this[a] === 'function') {
this[a](key);
} else {
this.bell();
}
};
this.close = () => {
this.out.write(cursor.show);