size-limit
Advanced tools
Comparing version 4.10.1 to 4.10.2
@@ -1,5 +0,5 @@ | ||
module.exports = async function calc (plugins, config, createSpinner) { | ||
module.exports = async function calc(plugins, config, createSpinner) { | ||
process.setMaxListeners(config.checks.reduce((a, i) => a + i.files.length, 1)) | ||
async function step (number) { | ||
async function step(number) { | ||
for (let plugin of plugins.list) { | ||
@@ -30,3 +30,3 @@ let spinner | ||
async function callMethodForEachPlugin (methodName) { | ||
async function callMethodForEachPlugin(methodName) { | ||
for (let plugin of plugins.list) { | ||
@@ -33,0 +33,0 @@ if (plugin[methodName]) { |
@@ -7,3 +7,3 @@ let { bold: b, yellow: y, red } = require('colorette') | ||
function npmCommands (pkg) { | ||
function npmCommands(pkg) { | ||
let add = 'npm install --save-dev ' | ||
@@ -19,10 +19,10 @@ let rm = 'npm remove ' | ||
module.exports = process => { | ||
function print (...lines) { | ||
function print(...lines) { | ||
process.stdout.write(lines.join('\n') + '\n') | ||
} | ||
function printError (...lines) { | ||
function printError(...lines) { | ||
process.stderr.write(lines.join('\n') + '\n') | ||
} | ||
function showHelp (plugins) { | ||
function showHelp(plugins) { | ||
print( | ||
@@ -71,7 +71,7 @@ y('size-limit [OPTION]… [FILE]…'), | ||
function showVersion () { | ||
function showVersion() { | ||
print(`size-limit ${ownPackage.version}`) | ||
} | ||
function showMigrationGuide (pkg) { | ||
function showMigrationGuide(pkg) { | ||
let { add } = npmCommands(pkg) | ||
@@ -87,3 +87,3 @@ printError( | ||
'', | ||
'For small (< 10 KB) libraries', | ||
'For small (< 10 kB) libraries', | ||
' ' + y(add + '@size-limit/preset-small-lib'), | ||
@@ -90,0 +90,0 @@ '', |
@@ -12,6 +12,6 @@ let { | ||
let { join } = require('path') | ||
let bytes = require('bytes') | ||
let bytes = require('bytes-iec') | ||
function createJsonReporter (process) { | ||
function print (data) { | ||
function createJsonReporter(process) { | ||
function print(data) { | ||
process.stdout.write(JSON.stringify(data, null, 2) + '\n') | ||
@@ -21,7 +21,7 @@ } | ||
return { | ||
error (err) { | ||
error(err) { | ||
print({ error: err.stack }) | ||
}, | ||
results (plugins, config) { | ||
results(plugins, config) { | ||
print( | ||
@@ -41,3 +41,3 @@ config.checks.map(i => { | ||
function getFixText (prefix, config) { | ||
function getFixText(prefix, config) { | ||
if (config.configPath) { | ||
@@ -55,12 +55,12 @@ if (config.configPath.endsWith('package.json')) { | ||
function createHumanReporter (process, isSilentMode = false) { | ||
function print (...lines) { | ||
function createHumanReporter(process, isSilentMode = false) { | ||
function print(...lines) { | ||
process.stdout.write(' ' + lines.join('\n ') + '\n') | ||
} | ||
function formatBytes (size) { | ||
function formatBytes(size) { | ||
return bytes.format(size, { unitSeparator: ' ' }) | ||
} | ||
function formatTime (seconds) { | ||
function formatTime(seconds) { | ||
if (seconds >= 1) { | ||
@@ -74,3 +74,3 @@ return Math.ceil(seconds * 10) / 10 + ' s' | ||
return { | ||
error (err) { | ||
error(err) { | ||
if (err.name === 'SizeLimitError') { | ||
@@ -95,3 +95,3 @@ let msg = err.message | ||
results (plugins, config) { | ||
results(plugins, config) { | ||
print('') | ||
@@ -98,0 +98,0 @@ for (let check of config.checks) { |
module.exports = { | ||
results (process, args, config) { | ||
results(process, args, config) { | ||
if (args && args.debug) { | ||
@@ -8,3 +8,3 @@ process.stdout.write(JSON.stringify(config, null, 2) + '\n') | ||
error (process, args, config) { | ||
error(process, args, config) { | ||
if (args && args.debug) { | ||
@@ -11,0 +11,0 @@ process.stderr.write(JSON.stringify(config, null, 2) + '\n') |
let { isAbsolute, dirname, join, relative } = require('path') | ||
let { lilconfig } = require('lilconfig') | ||
let globby = require('globby') | ||
let bytes = require('bytes') | ||
let bytes = require('bytes-iec') | ||
@@ -26,3 +26,3 @@ let SizeLimitError = require('./size-limit-error') | ||
function isStrings (value) { | ||
function isStrings(value) { | ||
if (!Array.isArray(value)) return false | ||
@@ -32,3 +32,3 @@ return value.every(i => typeof i === 'string') | ||
function isStringsOrUndefined (value) { | ||
function isStringsOrUndefined(value) { | ||
let type = typeof value | ||
@@ -38,3 +38,3 @@ return type === 'undefined' || type === 'string' || isStrings(value) | ||
function checkChecks (plugins, checks) { | ||
function checkChecks(plugins, checks) { | ||
if (!Array.isArray(checks)) { | ||
@@ -73,11 +73,11 @@ throw new SizeLimitError('noArrayConfig') | ||
function toAbsolute (file, cwd) { | ||
function toAbsolute(file, cwd) { | ||
return isAbsolute(file) ? file : join(cwd, file) | ||
} | ||
function toName (files, cwd) { | ||
function toName(files, cwd) { | ||
return files.map(i => (i.startsWith(cwd) ? relative(cwd, i) : i)).join(', ') | ||
} | ||
module.exports = async function getConfig (plugins, process, args, pkg) { | ||
module.exports = async function getConfig(plugins, process, args, pkg) { | ||
let config = { | ||
@@ -84,0 +84,0 @@ cwd: process.cwd() |
@@ -1,2 +0,2 @@ | ||
function toArray (obj) { | ||
function toArray(obj) { | ||
return typeof obj === 'object' ? Object.keys(obj) : [] | ||
@@ -6,3 +6,3 @@ } | ||
class Plugins { | ||
constructor (list) { | ||
constructor(list) { | ||
this.list = list | ||
@@ -12,3 +12,3 @@ this.isEmpty = list.length === 0 | ||
has (type) { | ||
has(type) { | ||
return this.list.some(i => i.name === `@size-limit/${type}`) | ||
@@ -18,3 +18,3 @@ } | ||
module.exports = function loadPlugins (pkg) { | ||
module.exports = function loadPlugins(pkg) { | ||
if (!pkg || !pkg.packageJson) return new Plugins([]) | ||
@@ -21,0 +21,0 @@ |
{ | ||
"name": "size-limit", | ||
"version": "4.10.1", | ||
"version": "4.10.2", | ||
"description": "CLI tool for Size Limit", | ||
@@ -21,11 +21,11 @@ "keywords": [ | ||
"dependencies": { | ||
"bytes": "^3.1.0", | ||
"bytes-iec": "^3.1.1", | ||
"chokidar": "^3.5.1", | ||
"ci-job-number": "^1.2.2", | ||
"colorette": "^1.2.2", | ||
"globby": "^11.0.2", | ||
"globby": "^11.0.3", | ||
"lilconfig": "^2.0.2", | ||
"ora": "^5.3.0", | ||
"ora": "^5.4.0", | ||
"read-pkg-up": "^7.0.1" | ||
} | ||
} |
let SizeLimitError = require('./size-limit-error') | ||
module.exports = function parseArgs (plugins, argv) { | ||
module.exports = function parseArgs(plugins, argv) { | ||
let args = { files: [] } | ||
@@ -5,0 +5,0 @@ for (let i = 2; i < argv.length; i++) { |
@@ -15,3 +15,3 @@ let readPkgUp = require('read-pkg-up') | ||
function throttle (fn) { | ||
function throttle(fn) { | ||
let next, running | ||
@@ -28,3 +28,3 @@ // istanbul ignore next | ||
async function findPlugins (parentPkg) { | ||
async function findPlugins(parentPkg) { | ||
let plugins = loadPlugins(parentPkg) | ||
@@ -41,3 +41,3 @@ | ||
module.exports = async process => { | ||
function hasArg (arg) { | ||
function hasArg(arg) { | ||
return process.argv.includes(arg) | ||
@@ -44,0 +44,0 @@ } |
@@ -52,3 +52,3 @@ const MESSAGES = { | ||
class SizeLimitError extends Error { | ||
constructor (type, ...args) { | ||
constructor(type, ...args) { | ||
super(MESSAGES[type](...args)) | ||
@@ -61,3 +61,3 @@ this.name = 'SizeLimitError' | ||
' "path": "dist/bundle.js",\n' + | ||
' "limit": "10 KB"\n' + | ||
' "limit": "10 kB"\n' + | ||
' }\n' + | ||
@@ -64,0 +64,0 @@ ' ]\n' |
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
27250
+ Addedbytes-iec@^3.1.1
+ Addedbytes-iec@3.1.1(transitive)
- Removedbytes@^3.1.0
- Removedbytes@3.1.2(transitive)
Updatedglobby@^11.0.3
Updatedora@^5.4.0