Browse Source

fix(email-plugin): Fix sorting of emails in dev-mailbox

Michael Bromley 4 years ago
parent
commit
57cc26eef6
1 changed files with 7 additions and 2 deletions
  1. 7 2
      packages/email-plugin/src/dev-mailbox.ts

+ 7 - 2
packages/email-plugin/src/dev-mailbox.ts

@@ -82,7 +82,12 @@ export class DevMailbox {
 
     private async getEmailList(outputPath: string) {
         const list = await fs.readdir(outputPath);
-        const contents: any[] = [];
+        const contents: Array<{
+            fileName: string;
+            date: string;
+            subject: string;
+            recipient: string;
+        }> = [];
         for (const fileName of list.filter(name => name.endsWith('.json'))) {
             const json = await fs.readFile(path.join(outputPath, fileName), 'utf-8');
             const content = JSON.parse(json);
@@ -94,7 +99,7 @@ export class DevMailbox {
             });
         }
         contents.sort((a, b) => {
-            return +new Date(b.date) - +new Date(a.date);
+            return a.fileName < b.fileName ? 1 : -1;
         });
         return contents;
     }