Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
fs.stat(filePath, async (err, stats) => {
if (!err && stats.isFile()) {
// read last line of the file to determine the number of blocks to replay
const lastLine = await readLastLines.read(filePath, 1);
const lastBlock = JSON.parse(lastLine);
const lastBockNumber = lastBlock.blockNumber;
// read the file from the start
lr = new LineByLineReader(filePath);
lr.on('line', async (line) => {
lr.pause();
if (line !== '') {
const block = JSON.parse(line);
const {
blockNumber,
timestamp,
transactions,
refSteemBlockNumber,
refSteemBlockId,
it("write pid file", function (done) {
const file = config.pidFile;
expect("bgpalerter.pid").to.equal(file);
if (file) {
readLastLines
.read(file, 1)
.then((line) => {
expect(parseInt(line)).to.equal(process.pid);
done();
});
}
});
return new Promise((resolve, reject) => {
ReadLastLines.read(file, 10).then(str => {
const lines = str.split("\n").filter(line => !!line);
const last = lines.pop();
const line = last.split(" ");
if (line.length !== 5) { throw new Error("expected tape to have 4 elements") }
if (line[0] === "BLOCK") {
const height = Number(line[1]);
resolve(height);
} else {
resolve(null);
}
}).catch(e => {
resolve(null);
});
});
}
if (argv.follow) {
this.ui.log('Log file has not been created yet, `--follow` only works on existing files', 'yellow');
}
return Promise.resolve();
}
prettyStream.on('error', (error) => {
if (!(error instanceof SyntaxError)) {
throw error;
}
});
prettyStream.pipe(this.ui.stdout);
return lastLines.read(logFileName, argv.number).then((lines) => {
lines.trim().split('\n').forEach(line => prettyStream.write(line));
if (argv.follow) {
const Tail = require('tail').Tail;
const tail = new Tail(logFileName);
tail.on('line', line => prettyStream.write(line, 'utf8'));
}
});
});
}
function (cb)
{
readLastLines.read(errorLogPath, lines)
.then((lines) => cb(null, lines));
}
], function (err, results)
router.get("/raw/out", function (req, res, next) {
reader.read(hb.log, 100).then((data) => res.send(convert(data)));
});
const accessed = (err, workbench) =>
{
if (!found)
{
if (!err)
{
found = true;
lines.read(workbench, 1).then((line) =>
{
if (line.startsWith("function injectGitFileStatus()"))
{
callback(new Error("vscode-explorer-git-status is already installed."), null);
}
else
{
callback(err, workbench);
}
});
}
else
{
processing.pop();
if (processing.length == 0)
{
router.get("/raw/error", function (req, res, next) {
reader.read(hb.error_log, 100).then((data) => res.send(convert(data)));
});