cached-commit-date

0.5.1 • Public • Published

A npm package to get the latest commit date for a given file path. As getting the commit date is a time consuming step (like 100 ms) those dates are cached so that subsequent queries for a commit date of the same file path would use the cache. I´m using it in my 11ty-powered website to show a posts date of modification.

Install

npm i cached-commit-date

Usage

const ccd = require('cached-commit-date');

//will return a date or null
let date = ccd.commitDate('./2020-07-04-learn-eleventy-from-scratch.md'); //2021-05-23T10:01:41.000Z
//if the file doesn´t exist or is not under git control 
//will return null and not throw an exception 

Clearing the cache

ccd.clearCache();

Configuration

There is no configuration.

/cached-commit-date/

    Package Sidebar

    Install

    npm i cached-commit-date

    Homepage

    ulf.codes

    Weekly Downloads

    4

    Version

    0.5.1

    License

    MIT

    Unpacked Size

    3.64 kB

    Total Files

    4

    Last publish

    Collaborators

    • ulfschneider