bundlesize
Advanced tools
Comparing version 0.8.0 to 0.9.0
#!/usr/bin/env node | ||
const { inspect } = require('util') | ||
const files = require('./src/files') | ||
@@ -10,4 +11,6 @@ const reporter = require('./src/reporter') | ||
process.on('unhandledRejection', function(reason, p) { | ||
console.log('Unhandled Promise: ', p, ' reason: ', reason) | ||
console.log('Unhandled Promise: ') | ||
console.log(inspect(p)) | ||
console.log(inspect(reason)) | ||
build.error() | ||
}) |
{ | ||
"name": "bundlesize", | ||
"version": "0.8.0", | ||
"version": "0.9.0", | ||
"description": "Keep your library size in check", | ||
@@ -8,3 +8,3 @@ "main": "index.js", | ||
"scripts": { | ||
"test": "node index" | ||
"test": "node index --debug" | ||
}, | ||
@@ -11,0 +11,0 @@ "keywords": [ |
@@ -60,16 +60,16 @@ <p align="center"> | ||
``` | ||
"path": "./dist/vendor-*.js", | ||
"maxSize": "3 Kb" | ||
``` | ||
"bundlesize": [ | ||
{ | ||
"path": "./dist/vendor-*.js", | ||
"maxSize": "3 Kb" | ||
}, | ||
{ | ||
"path": "./dist/chunk-*.js", | ||
"maxSize": "3 Kb" | ||
} | ||
] | ||
This makes it great for using with applications that are bundled with another tool. | ||
Alternate example: | ||
``` | ||
"path": "./dist/chunk-*.js", | ||
"maxSize": "3 Kb" | ||
``` | ||
This will match multiple files if necessary and create a new row for each file. | ||
This makes it great for using with applications that are bundled with another tool. It will match multiple files if necessary and create a new row for each file. | ||
@@ -76,0 +76,0 @@ |
const axios = require('axios') | ||
const { repo, sha } = require('ci-env') | ||
const token = require('./token') | ||
const debug = require('./debug') | ||
@@ -11,3 +12,7 @@ const url = 'https://bundlesize-store.now.sh/values' | ||
debug('api enabled', enabled) | ||
const get = () => { | ||
debug('fetching values', '...') | ||
return axios | ||
@@ -20,5 +25,9 @@ .get(`${url}?repo=${repo}&token=${token}`) | ||
} | ||
debug('master values', values) | ||
return values | ||
}) | ||
.catch(error => console.log(error)) | ||
.catch(error => { | ||
debug('fetching failed', error) | ||
console.log(error) | ||
}) | ||
} | ||
@@ -28,2 +37,4 @@ | ||
if (repo && token) { | ||
debug('saving values') | ||
axios | ||
@@ -30,0 +41,0 @@ .post(url, { repo, token, sha, values }) |
const Build = require('github-build') | ||
const { repo, sha, event } = require('ci-env') | ||
const token = require('./token') | ||
const debug = require('./debug') | ||
@@ -15,2 +16,7 @@ let pass = () => {} // noop | ||
debug('token exists', !!token) | ||
debug('repo', repo) | ||
debug('sha', sha) | ||
debug('event', event) | ||
if (token && event === 'push') { | ||
@@ -17,0 +23,0 @@ build.start() |
const readPkgUp = require('read-pkg-up') | ||
const pkg = readPkgUp.sync().pkg | ||
const program = require('commander') | ||
const { error } = require('prettycli') | ||
const { info, error } = require('prettycli') | ||
const debug = require('./debug') | ||
@@ -14,2 +15,3 @@ /* Config from package.json */ | ||
.option('-s, --max-size [maxSize]', 'maximum size threshold (3Kb)') | ||
.option('--debug', 'run in debug mode') | ||
.parse(process.argv) | ||
@@ -43,2 +45,6 @@ | ||
debug('cli config', cliConfig) | ||
debug('package json config', packageJSONconfig) | ||
debug('selected config', config) | ||
module.exports = config |
@@ -5,3 +5,5 @@ const fs = require('fs') | ||
const gzip = require('gzip-size') | ||
const { error } = require('prettycli') | ||
const config = require('./config') | ||
const debug = require('./debug') | ||
@@ -12,9 +14,15 @@ const files = [] | ||
const paths = glob.sync(file.path) | ||
paths.map(path => { | ||
const size = gzip.sync(fs.readFileSync(path, 'utf8')) | ||
const maxSize = bytes(file.threshold || file.maxSize) | ||
files.push({ maxSize, path, size }) | ||
}) | ||
if (!paths.length) { | ||
error('There is no matching file for ' + file.path, { silent: true }) | ||
} else { | ||
paths.map(path => { | ||
const size = gzip.sync(fs.readFileSync(path, 'utf8')) | ||
const maxSize = bytes(file.threshold || file.maxSize) | ||
files.push({ maxSize, path, size }) | ||
}) | ||
} | ||
}) | ||
debug('files', files) | ||
module.exports = files |
const bytes = require('bytes') | ||
const { error, warn, info } = require('prettycli') | ||
const { event, branch } = require('ci-env') | ||
const build = require('./build') | ||
const api = require('./api') | ||
const { event, branch } = require('ci-env') | ||
const debug = require('./debug') | ||
@@ -45,5 +46,6 @@ const compare = (files, masterValues = {}) => { | ||
} | ||
} | ||
if (files.length === 1) globalMessage = message | ||
} | ||
if (files.length === 1) globalMessage = message | ||
debug('message', message) | ||
}) | ||
@@ -60,2 +62,4 @@ | ||
} | ||
debug('global message', globalMessage) | ||
} | ||
@@ -62,0 +66,0 @@ |
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
10978
11
199