2016-09-16 17:58:41 +00:00
|
|
|
#!/usr/bin/env node
|
|
|
|
var fs = require('fs')
|
|
|
|
var execSync = require('child_process').execSync
|
|
|
|
|
2016-09-16 19:03:40 +00:00
|
|
|
console.log('Rebuilding Mercury')
|
2016-11-29 18:06:55 +00:00
|
|
|
execSync('MERCURY_TEST_BUILD=true npm run build')
|
2016-09-16 17:58:41 +00:00
|
|
|
|
2016-11-29 18:06:55 +00:00
|
|
|
var Mercury = require('./dist/mercury.test')
|
2016-09-16 17:58:41 +00:00
|
|
|
|
|
|
|
var url = process.argv[2]
|
|
|
|
|
2016-09-16 19:03:40 +00:00
|
|
|
console.log(`Fetching link`)
|
2016-09-30 16:26:25 +00:00
|
|
|
Mercury.parse(url, null, { fallback: false }).then(function(result) {
|
2016-09-16 19:03:40 +00:00
|
|
|
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}`)
|
2016-09-16 17:58:41 +00:00
|
|
|
})
|
|
|
|
|