Skip to content

Instantly share code, notes, and snippets.

@LekoArts
Created November 5, 2019 08:48
Show Gist options
  • Save LekoArts/a4ece3918bf452fa1be882d712938a4b to your computer and use it in GitHub Desktop.
Save LekoArts/a4ece3918bf452fa1be882d712938a4b to your computer and use it in GitHub Desktop.
const spawn = require('cross-spawn')
/**
* GetLastUpdatedTimestamp - Get the last time a file was commited to GitHub and therefore was updated
* @param filepath
* @returns {number} - Date
*/
const getLastUpdatedTimestamp = filepath =>
parseInt(spawn.sync('git', ['log', '-1', '--format=%ct', filepath]).stdout.toString('utf-8'), 10) * 1000
module.exports = getLastUpdatedTimestamp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment