Commit 45bfc64

Anton Golub <antongolub@antongolub.com>
2023-10-12 22:52:31
fix: fix src paths
1 parent 6eb345f
src/present-badges.ts
@@ -21,9 +21,9 @@ export const presentBadges = (
   omitBadges: string[],
   compact: boolean,
 ): Badge[] => {
-  const newBadges: Badge[] = []
   const presenters: BadgePresenter[] = allBadges.map((m) => m.default)
   for (const presenter of presenters) {
+    const newBadges: Badge[] = []
     const grant = badgeCollection(newBadges)
     presenter.present(data, grant)
 
@@ -32,9 +32,10 @@ export const presentBadges = (
       const baseDir = path.basename(path.dirname(fileURLToPath(presenter.url)))
       b.image = `https://github.com/my-badges/my-badges/blob/master/src/all-badges/${baseDir}/${b.id}.png?raw=true`
     }
+
+    userBadges = mergeBadges(userBadges, newBadges)
   }
 
-  userBadges = mergeBadges(userBadges, newBadges)
 
   if (compact) {
     for (const presenter of presenters) {
test/present-badges.test.ts
@@ -49,7 +49,7 @@ describe('present-badges', () => {
           '\n' +
           "<sup>I have push, maintainer or admin permissions, so I'm definitely an author.<sup>\n",
         image:
-          'https://github.com/my-badges/my-badges/blob/master/src/all-badges/pr-collaboration/stars-100.png?raw=true',
+          'https://github.com/my-badges/my-badges/blob/master/src/all-badges/stars/stars-100.png?raw=true',
       },
       {
         id: 'stars-500',
@@ -62,7 +62,7 @@ describe('present-badges', () => {
           '\n' +
           "<sup>I have push, maintainer or admin permissions, so I'm definitely an author.<sup>\n",
         image:
-          'https://github.com/my-badges/my-badges/blob/master/src/all-badges/pr-collaboration/stars-500.png?raw=true',
+          'https://github.com/my-badges/my-badges/blob/master/src/all-badges/stars/stars-500.png?raw=true',
       },
     ])
   })
@@ -88,7 +88,7 @@ describe('present-badges', () => {
           '\n' +
           "<sup>I have push, maintainer or admin permissions, so I'm definitely an author.<sup>\n",
         image:
-          'https://github.com/my-badges/my-badges/blob/master/src/all-badges/pr-collaboration/stars-100.png?raw=true',
+          'https://github.com/my-badges/my-badges/blob/master/src/all-badges/stars/stars-100.png?raw=true',
       },
     ])
   })
@@ -115,7 +115,7 @@ describe('present-badges', () => {
           '\n' +
           "<sup>I have push, maintainer or admin permissions, so I'm definitely an author.<sup>\n",
         image:
-          'https://github.com/my-badges/my-badges/blob/master/src/all-badges/pr-collaboration/stars-2000.png?raw=true',
+          'https://github.com/my-badges/my-badges/blob/master/src/all-badges/stars/stars-2000.png?raw=true',
       },
     ])
   })