diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f37177a --- /dev/null +++ b/.gitignore @@ -0,0 +1,31 @@ +# Created by .gitignore support plugin (hsz.mobi) +### Node template +# Logs +logs +*.log + +# Runtime data +pids +*.pid +*.seed + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directory +# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git- +node_modules + +.idea diff --git a/README.md b/README.md new file mode 100644 index 0000000..451cfdd --- /dev/null +++ b/README.md @@ -0,0 +1,8 @@ +# Cli Tool to extract html content from a eml file + +## Usage + + +```bash +node parse.js -i /path/to/email.eml -o /path/to/email.html +``` \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..3e83a3e --- /dev/null +++ b/package.json @@ -0,0 +1,20 @@ +{ + "name": "eml_parser", + "version": "1.0.0", + "description": "Parse eml file and output html", + "main": "parse.js", + "dependencies": { + "mailparser": "^0.4.6", + "nomnom": "^1.8.1" + }, + "devDependencies": {}, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [ + "eml", + "html" + ], + "author": "Aco Mitevski", + "license": "ISC" +} diff --git a/parse.js b/parse.js new file mode 100755 index 0000000..7c5840f --- /dev/null +++ b/parse.js @@ -0,0 +1,25 @@ +#!/usr/bin/env node + +var MailParser = require('mailparser').MailParser; +var mailparser = new MailParser(); +var fs = require('fs'); + +var opts = require("nomnom") + .option('infile', { + abbr: 'i', + required: true, + help: 'Specify input file' + }) + .option('outfile', { + abbr: 'o', + required: true, + help: 'Specify output file' + }) + .parse(); + + +mailparser.on("end", function(mail){ + fs.writeFileSync(opts.outfile, mail.html); +}); + +fs.createReadStream(opts.infile).pipe(mailparser);