Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return throughObj((file, encoding, callback) => {
gutil.log(`Generating treemap for ${gutil.colors.magenta(file.relative)}`);
if (typeof loadSourceMap !== 'undefined') {
const data = loadSourceMap(file.path, `${file.path}.map`);
const sizes = computeGeneratedFileSizes(data.mapConsumer, data.jsData);
const asizes = adjustSourcePaths(sizes, true, '', '');
const tsv = 'Source\tSize\n' + Object.keys(asizes).map(k => `${k}\t${asizes[k]}`).join('\n');
file.contents = new Buffer(tsv);
file.path = gutil.replaceExtension(file.path, '.tsv');
return callback(null, file);
}
gutil.log('Running source-map-explorer in shell');
execa.stdout('source-map-explorer', ['--tsv', file.path, `${file.path}.map`])
.then(result => {
file.contents = new Buffer(result);
file.path = gutil.replaceExtension(file.path, '.tsv');
callback(null, file);
})
.catch(err => {
console.error(err); // eslint-disable-line no-console
files.forEach((f) => {
console.error('> processing', f);
const data = sourcemapExplorer.loadSourceMap(f, `${f}.map`);
const sizes = sourcemapExplorer.computeGeneratedFileSizes(data.mapConsumer, data.jsData);
const files = sourcemapExplorer.adjustSourcePaths(sizes.files, false);
updateThirdPartyModules(modules, files);
});