astro-compressor
Advanced tools
Comparing version 0.1.3 to 0.2.0
@@ -0,1 +1,11 @@ | ||
## v0.2.0 | ||
> 2022-12-29 | ||
## Summary | ||
Release v0.2.0 is our best yet! Many bugs were squashed, and yet more features added. | ||
### Commits | ||
- [[`f0840e5`](https://github.com/sondr3/astro-compressor)] Remove globby dependency, use stdlib | ||
## v0.1.3 | ||
@@ -2,0 +12,0 @@ > 2022-12-27 |
import { createReadStream, createWriteStream } from "node:fs"; | ||
import { readdir } from "node:fs/promises"; | ||
import { resolve } from "node:path"; | ||
import { hrtime } from "node:process"; | ||
import { promises as stream } from "node:stream"; | ||
import { createBrotliCompress, createGzip } from "node:zlib"; | ||
import { globby } from "globby"; | ||
import { Logger } from "./logger.js"; | ||
async function* walkDir(dir) { | ||
const entries = await readdir(dir, { withFileTypes: true }); | ||
for (const entry of entries) { | ||
const name = resolve(dir, entry.name); | ||
if (entry.isDirectory()) { | ||
yield* walkDir(name); | ||
} | ||
else if (filterFile(entry.name)) { | ||
yield name; | ||
} | ||
} | ||
} | ||
const filterFile = (file) => { | ||
@@ -12,4 +25,5 @@ return [".css", ".js", ".html", ".xml", ".cjs", ".mjs", ".svg", ".txt"].some((ext) => file.endsWith(ext)); | ||
const start = hrtime.bigint(); | ||
const files = (await globby(`${dir.pathname}/**/*`)).filter(filterFile); | ||
for (const file of files) { | ||
let counter = 0; | ||
for await (const file of walkDir(dir.pathname)) { | ||
counter += 1; | ||
const source = createReadStream(file); | ||
@@ -21,8 +35,9 @@ const destination = createWriteStream(`${file}.gz`); | ||
const end = hrtime.bigint(); | ||
Logger.success(`finished gzip of ${files.length} files in ${(end - start) / 1000000n}m`); | ||
Logger.success(`finished gzip of ${counter} files in ${(end - start) / 1000000n}m`); | ||
}; | ||
export const brotli = async (dir) => { | ||
const start = hrtime.bigint(); | ||
const files = (await globby(`${dir.pathname}/**/*`)).filter(filterFile); | ||
for (const file of files) { | ||
let counter = 0; | ||
for await (const file of walkDir(dir.pathname)) { | ||
counter += 1; | ||
const source = createReadStream(file); | ||
@@ -34,4 +49,4 @@ const destination = createWriteStream(`${file}.br`); | ||
const end = hrtime.bigint(); | ||
Logger.success(`finished brotli of ${files.length} files in ${(end - start) / 1000000n}m`); | ||
Logger.success(`finished brotli of ${counter} files in ${(end - start) / 1000000n}m`); | ||
}; | ||
//# sourceMappingURL=compress.js.map |
{ | ||
"name": "astro-compressor", | ||
"version": "0.1.3", | ||
"version": "0.2.0", | ||
"description": "A gzip and brotli compressor for Astro", | ||
@@ -30,5 +30,2 @@ "type": "module", | ||
], | ||
"dependencies": { | ||
"globby": "13.1.3" | ||
}, | ||
"devDependencies": { | ||
@@ -35,0 +32,0 @@ "@sondr3/eslint-config": "0.7.1", |
@@ -37,3 +37,3 @@ <h1 align="center">astro-compressor</h1> | ||
# Using NPM | ||
npm run astro add astro-compressor | ||
npx astro add astro-compressor | ||
# Using Yarn | ||
@@ -40,0 +40,0 @@ yarn astro add astro-compressor |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
13858
0
101
- Removedglobby@13.1.3
- Removed@nodelib/fs.scandir@2.1.5(transitive)
- Removed@nodelib/fs.stat@2.0.5(transitive)
- Removed@nodelib/fs.walk@1.2.8(transitive)
- Removedbraces@3.0.3(transitive)
- Removeddir-glob@3.0.1(transitive)
- Removedfast-glob@3.3.2(transitive)
- Removedfastq@1.17.1(transitive)
- Removedfill-range@7.1.1(transitive)
- Removedglob-parent@5.1.2(transitive)
- Removedglobby@13.1.3(transitive)
- Removedignore@5.3.2(transitive)
- Removedis-extglob@2.1.1(transitive)
- Removedis-glob@4.0.3(transitive)
- Removedis-number@7.0.0(transitive)
- Removedmerge2@1.4.1(transitive)
- Removedmicromatch@4.0.8(transitive)
- Removedpath-type@4.0.0(transitive)
- Removedpicomatch@2.3.1(transitive)
- Removedqueue-microtask@1.2.3(transitive)
- Removedreusify@1.0.4(transitive)
- Removedrun-parallel@1.2.0(transitive)
- Removedslash@4.0.0(transitive)
- Removedto-regex-range@5.0.1(transitive)