Commit 33a3c4a

Anton Medvedev <anton@medv.io>
2024-07-05 22:54:54
Add latest helper
1 parent 75896ef
Changed files (6)
badges
cosmetic-commit
delorean
spooky-commit
time-of-commit
src
badges/cosmetic-commit/cosmetic-commit.ts
@@ -1,4 +1,4 @@
-import { Commit, define } from '#src'
+import { Commit, define, latest } from '#src'
 
 export default define({
   url: import.meta.url,
@@ -24,9 +24,3 @@ export default define({
     }
   },
 })
-
-function latest(a: Commit, b: Commit) {
-  return (
-    new Date(b.committedDate).getTime() - new Date(a.committedDate).getTime()
-  )
-}
badges/delorean/delorean.ts
@@ -1,4 +1,4 @@
-import { Commit, define } from '#src'
+import { Commit, define, latest } from '#src'
 
 export default define({
   url: import.meta.url,
@@ -23,9 +23,3 @@ export default define({
     }
   },
 })
-
-function latest(a: Commit, b: Commit) {
-  return (
-    new Date(b.committedDate).getTime() - new Date(a.committedDate).getTime()
-  )
-}
badges/spooky-commit/spooky-commit.ts
@@ -1,4 +1,4 @@
-import { Commit, define } from '#src'
+import { Commit, define, latest } from '#src'
 
 export default define({
   url: import.meta.url,
@@ -23,9 +23,3 @@ export default define({
     }
   },
 })
-
-function latest(a: Commit, b: Commit) {
-  return (
-    new Date(b.committedDate).getTime() - new Date(a.committedDate).getTime()
-  )
-}
badges/time-of-commit/time-of-commit.ts
@@ -1,4 +1,4 @@
-import { Commit, define, User } from '#src'
+import { Commit, define, latest, User } from '#src'
 
 export default define({
   url: import.meta.url,
@@ -60,12 +60,6 @@ export default define({
   },
 })
 
-function latest(a: Commit, b: Commit) {
-  return (
-    new Date(b.committedDate).getTime() - new Date(a.committedDate).getTime()
-  )
-}
-
 function guessTimezone(user: User) {
   const location = user.location ? user.location.toLowerCase() : ''
   const regexMapping = [
src/index.ts
@@ -1,3 +1,3 @@
 export { define } from './badges.js'
 export { Repo, User, Issue, Pull, Commit } from './collect/types.js'
-export { linkCommit, linkIssue, linkPull } from './utils.js'
+export { linkCommit, linkIssue, linkPull, latest } from './utils.js'
src/utils.ts
@@ -44,3 +44,9 @@ export function execWithOutput(command: string, args: string[]): string {
   }
   return p.stdout.toString()
 }
+
+export function latest(a: Commit, b: Commit) {
+  return (
+    new Date(b.committedDate).getTime() - new Date(a.committedDate).getTime()
+  )
+}