Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only output total size? #51

Closed
Siilwyn opened this issue Jun 7, 2018 · 3 comments
Closed

Only output total size? #51

Siilwyn opened this issue Jun 7, 2018 · 3 comments

Comments

@Siilwyn
Copy link

Siilwyn commented Jun 7, 2018

👋 would you accept at PR that adds a flag to only output the total size? I want to run this module from in a CI task and fail if the total size goes about a certain number. Couldn't find any module that does this out of the box.

@alshakero
Copy link
Collaborator

It seems your need is fulfilled by https://github.com/siddharthkp/bundlesize. Have you checked it out?

@Siilwyn
Copy link
Author

Siilwyn commented Jun 7, 2018

@alshakero sadly not, it doesn't include the node modules.

@siddharthkp
Copy link
Owner

siddharthkp commented Jun 8, 2018

@Siilwyn Hey! This is not something cost-of-modules is good for.

You might like dirsize or get-folder-size

You would already install node_modules in your CI, you can run these on the CLI or with a script:

#!/usr/bin/env node

const getSize = require('get-folder-size') // gives size in bytes
const bytes = require('bytes')

const limit = process.argv[2] // accept size as a parameter
const limitInBytes = bytes(limit, { unit: 'B' })

getSize('node_modules', (err, size) => {
  if (size > limitInBytes) {
    console.error('whoa whoa whoa hold it right here')
    process.exit(1)
  }
})

You can use the above with node size-test 150MB

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants