Last active
February 27, 2019 12:40
-
-
Save kribblo/bd3fb5531acabd01c0b3cffe47306b4d to your computer and use it in GitHub Desktop.
Check minimum size of a file on command line (node) or in npm run scripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
const fs = require('fs'); | |
if(process.argv.length < 4) { | |
console.error('Usage:', 'node check-size.js file size'); | |
process.exit(1); | |
} | |
const file = process.argv[2]; | |
const minSize = process.argv[3]; | |
const stat = fs.statSync(file); | |
if(stat.size < minSize) { | |
console.error(file, 'is', stat.size, 'bytes, which is smaller than', minSize); | |
process.exit(1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment