[
  {
    "path": ".editorconfig",
    "content": "root = true\n\n[*]\nindent_style = tab\nend_of_line = lf\ncharset = utf-8\ntrim_trailing_whitespace = true\ninsert_final_newline = true\n\n[*.yml]\nindent_style = space\nindent_size = 2\n"
  },
  {
    "path": ".gitattributes",
    "content": "* text=auto eol=lf\n"
  },
  {
    "path": ".github/workflows/main.yml",
    "content": "name: CI\non:\n  - push\n  - pull_request\njobs:\n  test:\n    name: Node.js ${{ matrix.node-version }}\n    runs-on: ubuntu-latest\n    strategy:\n      fail-fast: false\n      matrix:\n        node-version:\n          - 16\n          - 14\n          - 12\n    steps:\n      - uses: actions/checkout@v2\n      - uses: actions/setup-node@v2\n        with:\n          node-version: ${{ matrix.node-version }}\n      - run: npm install\n      - run: npm test\n"
  },
  {
    "path": ".gitignore",
    "content": "node_modules\nyarn.lock\n"
  },
  {
    "path": ".npmrc",
    "content": "package-lock=false\n"
  },
  {
    "path": "cli.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\nimport fs from 'node:fs';\nimport meow from 'meow';\nimport prettyBytes from 'pretty-bytes';\nimport {gzipSizeSync} from 'gzip-size';\nimport chalk from 'chalk';\nimport getStdin from 'get-stdin';\n\nconst cli = meow(`\n\tUsage\n\t  $ gzip-size <file>\n\t  $ cat <file> | gzip-size\n\n\tOptions\n\t  --level             Compression level [0-9] (Default: 9)\n\t  --raw               Display value in bytes\n\t  --include-original  Include original size\n\n\tExamples\n\t  $ gzip-size unicorn.png\n\t  192 kB\n\t  $ gzip-size unicorn.png --raw\n\t  192256\n\t  $ gzip-size unicorn.png --include-original\n\t  392 kB → 192 kB\n`, {\n\timportMeta: import.meta,\n\tflags: {\n\t\tlevel: {\n\t\t\ttype: 'number',\n\t\t},\n\t\traw: {\n\t\t\ttype: 'boolean',\n\t\t},\n\t\tincludeOriginal: {\n\t\t\ttype: 'boolean',\n\t\t},\n\t},\n});\n\nconst [input] = cli.input;\n\nif (!input && process.stdin.isTTY) {\n\tconsole.error('Specify a file path');\n\tprocess.exit(1);\n}\n\nconst options = {};\nif (cli.flags.level) {\n\toptions.level = cli.flags.level;\n}\n\nfunction output(data) {\n\tconst originalSize = data.length;\n\tconst gzippedSize = gzipSizeSync(data);\n\n\tlet output = cli.flags.raw ? gzippedSize : prettyBytes(gzippedSize);\n\tif (cli.flags.includeOriginal) {\n\t\toutput = (cli.flags.raw ? originalSize : prettyBytes(originalSize)) + chalk.dim(' → ') + output;\n\t}\n\n\tconsole.log(output);\n}\n\n(async () => {\n\tif (input) {\n\t\toutput(fs.readFileSync(input));\n\t} else {\n\t\toutput(await getStdin.buffer());\n\t}\n})();\n"
  },
  {
    "path": "license",
    "content": "MIT License\n\nCopyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)\n\nPermission 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:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE 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.\n"
  },
  {
    "path": "package.json",
    "content": "{\n\t\"name\": \"gzip-size-cli\",\n\t\"version\": \"5.1.0\",\n\t\"description\": \"Get the gzipped size of a file or stdin\",\n\t\"license\": \"MIT\",\n\t\"repository\": \"sindresorhus/gzip-size-cli\",\n\t\"funding\": \"https://github.com/sponsors/sindresorhus\",\n\t\"author\": {\n\t\t\"name\": \"Sindre Sorhus\",\n\t\t\"email\": \"sindresorhus@gmail.com\",\n\t\t\"url\": \"https://sindresorhus.com\"\n\t},\n\t\"type\": \"module\",\n\t\"bin\": {\n\t\t\"gzip-size\": \"./cli.js\"\n\t},\n\t\"engines\": {\n\t\t\"node\": \">=12\"\n\t},\n\t\"scripts\": {\n\t\t\"test\": \"xo && ava\"\n\t},\n\t\"files\": [\n\t\t\"cli.js\"\n\t],\n\t\"keywords\": [\n\t\t\"cli-app\",\n\t\t\"cli\",\n\t\t\"zlib\",\n\t\t\"gzip\",\n\t\t\"compressed\",\n\t\t\"size\",\n\t\t\"file\",\n\t\t\"stdin\"\n\t],\n\t\"dependencies\": {\n\t\t\"chalk\": \"^4.1.2\",\n\t\t\"get-stdin\": \"^9.0.0\",\n\t\t\"gzip-size\": \"^7.0.0\",\n\t\t\"meow\": \"^10.1.2\",\n\t\t\"pretty-bytes\": \"^5.6.0\"\n\t},\n\t\"devDependencies\": {\n\t\t\"ava\": \"^3.15.0\",\n\t\t\"execa\": \"^6.0.0\",\n\t\t\"xo\": \"^0.46.4\"\n\t}\n}\n"
  },
  {
    "path": "readme.md",
    "content": "# gzip-size-cli\n\n> Get the gzipped size of a file or stdin\n\n## Install\n\n```sh\nnpm install --global gzip-size-cli\n```\n\n## Usage\n\n```\n$ gzip-size --help\n\n  Usage\n    $ gzip-size <file>\n    $ cat <file> | gzip-size\n\n  Options\n    --level             Compression level [0-9] (Default: 9)\n    --raw               Display value in bytes\n    --include-original  Include original size\n\n  Examples\n    $ gzip-size unicorn.png\n    192 kB\n    $ gzip-size unicorn.png --raw\n    192256\n    $ gzip-size unicorn.png --include-original\n    392 kB → 192 kB\n```\n\n## Related\n\n- [gzip-size](https://github.com/sindresorhus/gzip-size) - API for this module\n"
  },
  {
    "path": "test.js",
    "content": "import fs from 'node:fs';\nimport {execa} from 'execa';\nimport test from 'ava';\nimport {gzipSizeSync} from 'gzip-size';\n\nconst fixture = fs.readFileSync('test.js', 'utf8');\n\ntest('main', async t => {\n\tconst {stdout} = await execa('./cli.js', ['test.js']);\n\tt.regex(stdout, /^\\d+ B$/);\n});\n\ntest('file', async t => {\n\tconst {stdout} = await execa('./cli.js', ['test.js', '--raw']);\n\tt.is(Number.parseInt(stdout, 10), gzipSizeSync(fixture));\n});\n\ntest('stdin', async t => {\n\tconst {stdout} = await execa('./cli.js', ['test.js', '--raw'], {\n\t\tinput: fs.createReadStream('test.js'),\n\t});\n\tt.is(Number.parseInt(stdout, 10), gzipSizeSync(fixture));\n});\n\ntest('include original', async t => {\n\tconst {stdout} = await execa('./cli.js', ['test.js', '--raw', '--include-original']);\n\tconst {size} = fs.statSync('test.js');\n\tt.is(Number.parseInt(stdout, 10), size);\n});\n\ntest('include original - stdin', async t => {\n\tconst {stdout} = await execa('./cli.js', ['--raw', '--include-original'], {\n\t\tinput: fs.createReadStream('test.js'),\n\t});\n\tconst {size} = fs.statSync('test.js');\n\tt.is(Number.parseInt(stdout, 10), size);\n});\n"
  }
]