Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const [input] = cli.input;
if (!input && process.stdin.isTTY) {
console.error('Specify a file path');
process.exit(1);
}
const source = input ? fs.createReadStream(input) : process.stdin;
const options = {};
if (cli.flags.level) {
options.level = Number(cli.flags.level);
}
source.pipe(gzipSize.stream(options)).on('gzip-size', size => {
console.log(cli.flags.raw ? size : prettyBytes(size));
});
return new Promise(resolve => {
const source = fs.createReadStream(file);
source.pipe(gzipSize.stream()).on('gzip-size', size => {
resolve(utils.prettyBytes(size));
});
});
};
return;
}
totalSize += size;
if (options.showFiles === true && size > 0) {
log(chalk.blue(file.relative), size);
}
fileCount++;
callback(null, file);
};
if (file.isStream()) {
if (options.gzip) {
file.contents.pipe(gzipSize.stream())
.on('error', finish)
.on('end', function () {
finish(null, this.gzipSize);
});
} else {
file.contents.pipe(new StreamCounter())
.on('error', finish)
.on('finish', function () {
finish(null, this.bytes);
});
}
return;
}
if (options.gzip) {