mercury-parser/preview
2016-09-16 15:10:14 -04:00

25 lines
575 B
JavaScript
Executable File

#!/usr/bin/env node
var fs = require('fs')
var execSync = require('child_process').execSync
console.log('Rebuilding Mercury')
execSync('npm run build')
var Mercury = require('./dist/mercury')
var url = process.argv[2]
console.log(`Fetching link`)
Mercury.parse(url).then(function(result) {
var htmlFile = './preview.html'
var jsonFile = './preview.json'
var html = `<h1>${result.title}</h1>${result.content}`
fs.writeFileSync(htmlFile, html)
fs.writeFileSync(jsonFile, JSON.stringify(result))
execSync(`open ${htmlFile}`)
execSync(`open ${jsonFile}`)
})