Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function logProgress(str) {
// A little bit of readline magic to not fill the screen with progress messages.
readline.clearLine(process.stdout, 0);
readline.cursorTo(process.stdout, 0, null);
process.stdout.write(str);
}
function onProgress(value: number) {
value = Math.round(value * 100);
readline.clearLine(process.stdout, 0);
readline.cursorTo(process.stdout, 0, 1);
console.log(`${value}%`);
if (process != null && process.send != null) process.send({ type: "progress", value });
}
function clearScreen() {
const blank = '\n'.repeat(process.stdout.rows);
console.log(blank);
readline.cursorTo(process.stdout, 0, 0);
readline.clearScreenDown(process.stdout);
}
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();
});
}
yield new Promise(function (resolve, reject) {
let rl = readline.createInterface({
input: fs.createReadStream(dictPath)
});
rl.on('line', function (line) {
//给dict对象 添加属性与对应的值
if (line && line.indexOf(splitCode) >= 0) {
let list = line.split(splitCode);
dict[list[0]] = list[1];
}
});
rl.on('close', function () {
resolve(dict);
})
});
}
function printMessage({
from = null,
me = null,
to = null,
text = "",
timestamp = new Date()
} = {}) {
const message = formatter(from, me, to, text, timestamp);
readline.clearLine(process.stdout, 0);
readline.cursorTo(process.stdout, 0);
process.stdout.write(message);
rl.prompt(true);
}
progress(message) {
this._currentProgressMessage = message;
readline.clearLine(process.stdout, 0);
readline.cursorTo(process.stdout, 0);
if (message) process.stdout.write(`${this._nextLoadingChar()} ${message}`);
}
function clear () {
readline.clearLine(writeStream);
readline.cursorTo(writeStream, 0);
}
function ask(question, callback) {
var rl = require('readline').createInterface({
input: process.stdin,
output: process.stdout
});
rl.question(question, function(answer) {
rl.close();
callback(answer);
});
}
function _askUser(cb) {
const rl = require('readline').createInterface({ input: process.stdin, output: process.stdout });
rl.question('\u001b[1;36mThere is a new version of Bit, would you like to update? [Y/n]: \u001b[0m', function (
answer
) {
cb(answer === 'y' || answer === 'Y');
rl.close();
});
}