rollup-plugin-filesize
Advanced tools
Comparing version 1.5.0 to 2.0.0
@@ -20,2 +20,3 @@ 'use strict'; | ||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var env = arguments[1]; | ||
@@ -34,12 +35,17 @@ var defaultOptions = { | ||
var getData = function getData(bundle, code) { | ||
var size = fileSize(Buffer.byteLength(code), opts.format); | ||
var gzipSize = opts.showGzippedSize ? fileSize(gzip.sync(code), opts.format) : ""; | ||
return opts.render(opts, size, gzipSize, bundle); | ||
}; | ||
if (env === "test") { | ||
return getData; | ||
} | ||
return { | ||
getData: function getData(bundle, code) { | ||
var size = fileSize(Buffer.byteLength(code), opts.format); | ||
var gzipSize = opts.showGzippedSize ? fileSize(gzip.sync(code), opts.format) : ""; | ||
return opts.render(opts, size, gzipSize, bundle); | ||
}, | ||
ongenerate: function ongenerate(bundle, _ref) { | ||
var code = _ref.code; | ||
console.log(this.getData(bundle, code)); | ||
console.log(getData(bundle, code)); | ||
} | ||
@@ -46,0 +52,0 @@ }; |
{ | ||
"name": "rollup-plugin-filesize", | ||
"version": "1.5.0", | ||
"version": "2.0.0", | ||
"description": "A rollup plugin to show filesize in the cli", | ||
@@ -43,4 +43,4 @@ "main": "dist/index.js", | ||
"babel-register": "^6.7.2", | ||
"rollup": "^0.48.0", | ||
"rollup-plugin-babel": "^2.3.9" | ||
"rollup": "^0.60.1", | ||
"rollup-plugin-babel": "^3.0.4" | ||
}, | ||
@@ -47,0 +47,0 @@ "ava": { |
@@ -27,3 +27,3 @@ import fileSize from "filesize"; | ||
export default function filesize(options = {}) { | ||
export default function filesize(options = {}, env) { | ||
let defaultOptions = { | ||
@@ -41,15 +41,19 @@ format: {}, | ||
const getData = function(bundle, code) { | ||
let size = fileSize(Buffer.byteLength(code), opts.format); | ||
let gzipSize = opts.showGzippedSize | ||
? fileSize(gzip.sync(code), opts.format) | ||
: ""; | ||
return opts.render(opts, size, gzipSize, bundle); | ||
}; | ||
if (env === "test") { | ||
return getData | ||
} | ||
return { | ||
getData(bundle, code) { | ||
let size = fileSize(Buffer.byteLength(code), opts.format); | ||
let gzipSize = opts.showGzippedSize | ||
? fileSize(gzip.sync(code), opts.format) | ||
: ""; | ||
return opts.render(opts, size, gzipSize, bundle); | ||
}, | ||
ongenerate(bundle, { code }) { | ||
console.log(this.getData(bundle, code)); | ||
console.log(getData(bundle, code)); | ||
} | ||
}; | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5436
92