Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.rootNode.onImmediateRender = this.onRender;
this.renderer = createRenderer({
terminalWidth: options.stdout.columns,
});
} else {
this.rootNode = dom.createNode('root');
this.rootNode.onRender = this.onRender;
this.renderer = createRenderer({
terminalWidth: options.stdout.columns,
});
}
this.log = logUpdate.create(options.stdout);
this.throttledLog = options.debug
? this.log
: throttle(this.log, {
leading: true,
trailing: true,
} as any);
// Ignore last render after unmounting a tree to prevent empty output before exit
this.isUnmounted = false;
// Store last output to only rerender when needed
this.lastOutput = '';
// This variable is used only in debug mode to store full static output
// so that it's rerendered every time, not just new static parts, like in non-debug mode
this.fullStaticOutput = '';
this.rootNode.onImmediateRender = this.onRender;
this.renderer = createExperimentalRenderer({
terminalWidth: options.stdout.columns
});
} else {
this.rootNode = dom.createNode('root');
this.rootNode.onRender = this.onRender;
this.renderer = createRenderer({
terminalWidth: options.stdout.columns
});
}
this.log = logUpdate.create(options.stdout);
this.throttledLog = options.debug ? this.log : throttle(this.log, {
leading: true,
trailing: true
});
// Ignore last render after unmounting a tree to prevent empty output before exit
this.isUnmounted = false;
// Store last output to only rerender when needed
this.lastOutput = '';
// This variable is used only in debug mode to store full static output
// so that it's rerendered every time, not just new static parts, like in non-debug mode
this.fullStaticOutput = '';
if (options.experimental) {
module.exports = function() {
// create writable stream
const stream = new Writable()
// ignore (do not print) chunk, just call next
stream._write = (chunk, enc, next) => { next() }
// use this stream for logUpdate calls
return logUpdate.create(stream)
}
it('LogUpdate to stream if testing is true', () => {
const m = new Multispinner(spinners, {testing: true})
assert.deepEqual(
logUpdate.create().toString(),
m.update.toString()
)
})
})
const
{ ProgressPlugin } = require('webpack'),
throttle = require('lodash.throttle'),
{ green, grey } = require('chalk'),
log = require('../helpers/logger')('app:progress'),
logUpdate = require('log-update'),
ms = require('ms')
const
isMinimalTerminal = require('../helpers/is-minimal-terminal'),
logLine = isMinimalTerminal
? () => {}
: logUpdate.create(process.stdout, { showCursor: true })
const
compilations = {},
barLength = 25,
barItems = Array.apply(null, { length: barLength })
let maxLengthName = 0
function isRunningGlobally () {
return Object.values(compilations).find(c => c.running) !== void 0
}
function renderBar (progress, color) {
const width = progress * (barLength / 100)
return barItems
const { ProgressPlugin } = require('webpack')
const throttle = require('lodash.throttle')
const { green, grey } = require('chalk')
const log = require('../helpers/logger')('app:progress')
const logUpdate = require('log-update')
const ms = require('ms')
const isMinimalTerminal = require('../helpers/is-minimal-terminal')
const logLine = isMinimalTerminal
? () => {}
: logUpdate.create(process.stdout, { showCursor: true })
const compilations = {}
const barLength = 25
const barItems = Array.apply(null, { length: barLength })
let maxLengthName = 0
function isRunningGlobally () {
return Object.values(compilations).find(c => c.running) !== void 0
}
function renderBar (progress, color) {
const width = progress * (barLength / 100)
return barItems
.map((_, index) => index < width ? '█' : ' ')
function run (opts, stdout, cb) {
var bby
var total = 0
var cnt = 0
var start = process.hrtime()
var progressInterval
var logUpdater = logUpdate.create(stdout)
var output
var parser
try {
bby = bestbuy({key: opts.key, debug: opts.debug})
} catch (err) {
return cb(err)
}
opts.format = opts.format.toLowerCase()
var dataStream = bby[`${opts.resource}AsStream`](opts.query, {
format: opts.format === 'csv' || opts.format === 'tsv' ? 'json' : opts.format,
show: opts.show,
sort: opts.sort
done() {
this.flush();
updateScreen.clear();
updateScreen.done();
this.release();
},
};
export function writeSync(fd, msg, flush) {
fs.writeSync(fd, msg);
if (flush) {
fs.fsyncSync(fd);
}
}
let updateScreen = logUpdate.create({
write(msg) {
writeSync(1, msg, false);
}
});
export default OutputRenderer;
if (this.options.height === 'auto' && this.options.width === 'auto') {
fallbackFit = 'box'
} else if (this.options.height === 'auto') {
fallbackFit = 'width'
} else if (this.options.width === 'auto') {
fallbackFit = 'height'
}
var fallbackOptions = {
fit: fallbackFit,
height: this.options.height === 'auto' ? '100%' : this.options.height.replace('px', ''),
width: this.options.width === 'auto' ? '100%' : this.options.width.replace('px', '')
}
}
this.log = logUpdate.create(this.options.output)
img.forEach(i => {
var buffer
if (Buffer.isBuffer(i)) {
buffer = i
} else if (i.indexOf('data:') === 0) {
var parsed = parseDataUri(i)
if (parsed) {
buffer = parsed.data
}
} else if (i.indexOf('http://') === 0 || i.indexOf('https://') === 0) {
var response = requestSync({ url: i, encoding: null })
if (response) {
startProgress(string, customStream) {
const stream = customStream || logUpdate.create(this.outputStream);
if (this.writeLevelVisible(this.writeLevel)) {
this.streaming = true;
this.progressInterval = setInterval(() => {
stream(
` ${chalk.green('loading:')} ${string} ${chalk.cyan.bold.dim(
frame()
)}`
);
}, 100);
}
}