mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-09-10 14:44:52 +08:00
[local-sync] Allow logging parsed messages to disk with NYLAS_DEBUG env var
Summary: I've found this useful for generating test cases and am tired of adding and removing this code! Test Plan: inspect output of /tmp/k2-parse-output Reviewers: juan Reviewed By: juan Differential Revision: https://phab.nylas.com/D3518
This commit is contained in:
parent
ac5c7e3d2c
commit
e5a9e2cc9e
1 changed files with 13 additions and 0 deletions
|
@ -3,6 +3,11 @@ const mimelib = require('mimelib');
|
||||||
const encoding = require('encoding');
|
const encoding = require('encoding');
|
||||||
const he = require('he');
|
const he = require('he');
|
||||||
|
|
||||||
|
const os = require('os');
|
||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path')
|
||||||
|
const mkdirp = require('mkdirp');
|
||||||
|
|
||||||
const {Imap} = require('isomorphic-core');
|
const {Imap} = require('isomorphic-core');
|
||||||
const Errors = require('./errors');
|
const Errors = require('./errors');
|
||||||
|
|
||||||
|
@ -163,6 +168,14 @@ async function parseFromImap(imapMessage, desiredParts, {db, accountId, folder})
|
||||||
parsedMessage.labels = await Label.findXGMLabels(xGmLabels)
|
parsedMessage.labels = await Label.findXGMLabels(xGmLabels)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (process.env.NYLAS_DEBUG) {
|
||||||
|
const outJSON = JSON.stringify({imapMessage, desiredParts, result: parsedMessage});
|
||||||
|
const outDir = path.join(os.tmpdir(), "k2-parse-output", folder.name)
|
||||||
|
const outFile = path.join(outDir, imapMessage.attributes.uid.toString());
|
||||||
|
mkdirp.sync(outDir);
|
||||||
|
fs.writeFileSync(outFile, outJSON);
|
||||||
|
}
|
||||||
|
|
||||||
return parsedMessage;
|
return parsedMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue