Initial commit
This commit is contained in:
24
node_modules/@11ty/eleventy/src/Util/DateGitFirstAdded.js
generated
vendored
Normal file
24
node_modules/@11ty/eleventy/src/Util/DateGitFirstAdded.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
import spawn from "cross-spawn";
|
||||
|
||||
function getGitFirstAddedTimeStamp(filePath) {
|
||||
return (
|
||||
parseInt(
|
||||
spawn
|
||||
.sync(
|
||||
"git",
|
||||
// Formats https://www.git-scm.com/docs/git-log#_pretty_formats
|
||||
// %at author date, UNIX timestamp
|
||||
["log", "--diff-filter=A", "--follow", "-1", "--format=%at", filePath],
|
||||
)
|
||||
.stdout.toString("utf-8"),
|
||||
) * 1000
|
||||
);
|
||||
}
|
||||
|
||||
// return a Date
|
||||
export default function (inputPath) {
|
||||
let timestamp = getGitFirstAddedTimeStamp(inputPath);
|
||||
if (timestamp) {
|
||||
return new Date(timestamp);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user