mirror of
https://github.com/postlight/mercury-parser
synced 2024-10-31 03:20:40 +00:00
25 lines
575 B
JavaScript
Executable File
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}`)
|
|
})
|
|
|