You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mercury-parser/preview

25 lines
602 B
JavaScript

#!/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, null, { fallback: false }).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}`)
})