It appears you have a well-structured Git repository with various files, including SVG icons and HTML documents. Here's a brief overview:
This commit is contained in:
+72
@@ -0,0 +1,72 @@
|
||||
#!/usr/bin/env node
|
||||
import process from 'node:process';
|
||||
import fs from 'node:fs';
|
||||
import meow from 'meow';
|
||||
import prettyBytes from 'pretty-bytes';
|
||||
import {gzipSizeSync} from 'gzip-size';
|
||||
import chalk from 'chalk';
|
||||
import getStdin from 'get-stdin';
|
||||
|
||||
const cli = meow(`
|
||||
Usage
|
||||
$ gzip-size <file>
|
||||
$ cat <file> | gzip-size
|
||||
|
||||
Options
|
||||
--level Compression level [0-9] (Default: 9)
|
||||
--raw Display value in bytes
|
||||
--include-original Include original size
|
||||
|
||||
Examples
|
||||
$ gzip-size unicorn.png
|
||||
192 kB
|
||||
$ gzip-size unicorn.png --raw
|
||||
192256
|
||||
$ gzip-size unicorn.png --include-original
|
||||
392 kB → 192 kB
|
||||
`, {
|
||||
importMeta: import.meta,
|
||||
flags: {
|
||||
level: {
|
||||
type: 'number',
|
||||
},
|
||||
raw: {
|
||||
type: 'boolean',
|
||||
},
|
||||
includeOriginal: {
|
||||
type: 'boolean',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const [input] = cli.input;
|
||||
|
||||
if (!input && process.stdin.isTTY) {
|
||||
console.error('Specify a file path');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const options = {};
|
||||
if (cli.flags.level) {
|
||||
options.level = cli.flags.level;
|
||||
}
|
||||
|
||||
function output(data) {
|
||||
const originalSize = data.length;
|
||||
const gzippedSize = gzipSizeSync(data);
|
||||
|
||||
let output = cli.flags.raw ? gzippedSize : prettyBytes(gzippedSize);
|
||||
if (cli.flags.includeOriginal) {
|
||||
output = (cli.flags.raw ? originalSize : prettyBytes(originalSize)) + chalk.dim(' → ') + output;
|
||||
}
|
||||
|
||||
console.log(output);
|
||||
}
|
||||
|
||||
(async () => {
|
||||
if (input) {
|
||||
output(fs.readFileSync(input));
|
||||
} else {
|
||||
output(await getStdin.buffer());
|
||||
}
|
||||
})();
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
{
|
||||
"name": "gzip-size-cli",
|
||||
"version": "5.1.0",
|
||||
"description": "Get the gzipped size of a file or stdin",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/gzip-size-cli",
|
||||
"funding": "https://github.com/sponsors/sindresorhus",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "https://sindresorhus.com"
|
||||
},
|
||||
"type": "module",
|
||||
"bin": {
|
||||
"gzip-size": "./cli.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"files": [
|
||||
"cli.js"
|
||||
],
|
||||
"keywords": [
|
||||
"cli-app",
|
||||
"cli",
|
||||
"zlib",
|
||||
"gzip",
|
||||
"compressed",
|
||||
"size",
|
||||
"file",
|
||||
"stdin"
|
||||
],
|
||||
"dependencies": {
|
||||
"chalk": "^4.1.2",
|
||||
"get-stdin": "^9.0.0",
|
||||
"gzip-size": "^7.0.0",
|
||||
"meow": "^10.1.2",
|
||||
"pretty-bytes": "^5.6.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "^3.15.0",
|
||||
"execa": "^6.0.0",
|
||||
"xo": "^0.46.4"
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
# gzip-size-cli
|
||||
|
||||
> Get the gzipped size of a file or stdin
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install --global gzip-size-cli
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```
|
||||
$ gzip-size --help
|
||||
|
||||
Usage
|
||||
$ gzip-size <file>
|
||||
$ cat <file> | gzip-size
|
||||
|
||||
Options
|
||||
--level Compression level [0-9] (Default: 9)
|
||||
--raw Display value in bytes
|
||||
--include-original Include original size
|
||||
|
||||
Examples
|
||||
$ gzip-size unicorn.png
|
||||
192 kB
|
||||
$ gzip-size unicorn.png --raw
|
||||
192256
|
||||
$ gzip-size unicorn.png --include-original
|
||||
392 kB → 192 kB
|
||||
```
|
||||
|
||||
## Related
|
||||
|
||||
- [gzip-size](https://github.com/sindresorhus/gzip-size) - API for this module
|
||||
Reference in New Issue
Block a user