Socket
Socket
Sign inDemoInstall

cachekill

Package Overview
Dependencies
3
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    cachekill

Simple command line cache busting tool which fingerprints files with a content hash.


Version published
Weekly downloads
66
increased by60.98%
Maintainers
1
Created
Weekly downloads
 

Changelog

Source

v2.0.0 (2021-02-18)

  • Breaking change: Node >= 14.8.0 is required from now on.
    • Uses the new ECMAScript module syntax (import/export) instead of require().
    • Uses top level await statements.

Readme

Source

cachekill

Last Version Lines of code Npm downloads Maintenance

Simple command line cache busting tool which fingerprints source files with a md5 content hash (either creating copies or renaming them) and replaces references to those files in target files with the new filenames.

There were already similar packages out there, but either they weren't actively mantained or they lacked some feature I wanted. This one is:

  • Fast, by doing all the IO asyncrhonously.
  • Modern, by handling promises using async/await.
  • Up to date with the few dependencies it has.
  • Compatible with globs.
  • Actively mantained.

:warning:  Warning: From v2.0.0, cachekill uses ECMAScript module syntax and top level await statements, which are supported unflagged from Node v13.0.0 and v14.8.0 respectively. Upgrade your Node version or stick to v1.1.0 for Node 10.0.0 or higher support.

Using cachekill

To install it: npm install cachekill (requires Node 14.8.0 or higher)

Run cachekill --help for usage information.

Options:
  -v, --version            Outputs the current version number
  -s, --source <files...>  Source file(s); a fingerprinted copy will be generated for each of them
  -t, --target <files...>  Target file(s); files with references to source files to be replaced
  -l, --length <length>    Length of the fingerprint (between 1-32); longer means less collisions (defaults to 32)
  -r, --rename             Rename source files with the fingerprint instead of generating copies
  -q, --quiet              Supresses console output
  -h, --help               Displays usage information

Both source and target can be a list or files or globs. It will work even in platforms and shells that don't support globbing (like Windows), because cachekill has support for expanding globs itself. Just make sure you quote the arguments so the glob expansion will not depend on the shell you run the command in.

Examples

Take this folder structure as a starting point:

└── assets
    ├── img
    │   ├── a.jpg
    │   └── b.jpg
    ├── css
    │   └── bundle.min.css
    ├── js
    │   └── bundle.min.js
    └── index.html

After running cachekill -s 'assets/**/!(*.html)' -t 'assets/**/*.{js,css,html}', you'd have:

└── assets
    ├── img
    │   ├── a.jpg
    │   ├── a-HASH.jpg
    │   ├── b.jpg
    │   └── b-HASH.jpg
    ├── css
    │   ├── bundle.min.css
    │   └── bundle.min-HASH.css
    ├── js
    │    ├── bundle.min.js
    │    └── bundle.min-HASH.js
    └── index.html

All files not ending with .html have been fingerprinted and all the occurrences of those in every .js, .css and .html files replaced by the new filenames.

If you run it with -r or --rename option, files would've been renamed instead of copied:

└── assets
    ├── img
    │   ├── a-HASH.jpg
    │   └── b-HASH.jpg
    ├── css
    │   └── bundle.min-HASH.css
    ├── js
    │   └── bundle.min-HASH.js
    └── index.html

License

MIT License (MIT)

Keywords

FAQs

Last updated on 17 Feb 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc