Files
wordpress-export-to-markdown/index.js
T

28 lines
783 B
JavaScript
Raw Normal View History

2020-01-16 17:44:50 +00:00
#!/usr/bin/env node
2020-01-14 10:26:50 -05:00
const path = require('path');
const process = require('process');
2020-01-14 10:26:50 -05:00
const wizard = require('./src/wizard');
const parser = require('./src/parser');
2019-12-17 13:52:09 -05:00
const writer = require('./src/writer');
2018-10-14 18:46:24 -04:00
2019-12-21 16:07:52 -05:00
(async () => {
2020-01-14 10:26:50 -05:00
// parse any command line arguments and run wizard
const config = await wizard.getConfig(process.argv);
2020-01-14 10:26:50 -05:00
// parse data from XML and do Markdown translations
const posts = await parser.parseFilePromise(config)
2020-01-14 10:26:50 -05:00
// write files, downloading images as needed
2019-12-21 16:07:52 -05:00
await writer.writeFilesPromise(posts, config);
2020-01-14 10:26:50 -05:00
// happy goodbye
console.log('\nAll done!');
console.log('Look for your output files in: ' + path.resolve(config.output));
2019-12-21 16:07:52 -05:00
})().catch(ex => {
2020-01-14 10:26:50 -05:00
// sad goodbye
console.log('\nSomething went wrong, execution halted early.');
2019-12-21 16:07:52 -05:00
console.error(ex);
});