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

34 lines
1.0 KiB
JavaScript
Raw Normal View History

2020-01-16 17:44:50 +00:00
#!/usr/bin/env node
2025-01-27 12:59:21 -05:00
import * as commander from 'commander';
2025-01-18 14:22:53 -05:00
import path from 'path';
2025-01-28 16:38:29 -05:00
import * as intake from './src/intake.js';
2025-02-07 17:49:31 -05:00
import * as parser from './src/parser.js';
import * as shared from './src/shared.js';
2025-01-18 14:22:53 -05:00
import * as writer from './src/writer.js';
2018-10-14 18:46:24 -04:00
2019-12-21 16:07:52 -05:00
(async () => {
2025-01-27 14:11:31 -05:00
// configure command line help output
2025-01-27 12:59:21 -05:00
commander.program
.name('node index.js')
.helpOption('-h, --help', 'See the thing you\'re looking at right now')
.addHelpText('after', '\nMore documentation is at https://github.com/lonekorean/wordpress-export-to-markdown')
// gather config options from command line and wizard
2025-02-07 17:49:31 -05:00
await intake.getConfig();
2020-01-14 10:26:50 -05:00
// parse data from XML and do Markdown translations
2025-02-07 17:49:31 -05:00
const posts = await parser.parseFilePromise()
2020-01-14 10:26:50 -05:00
2025-01-27 12:59:21 -05:00
// write files and download images
2025-02-07 17:49:31 -05:00
await writer.writeFilesPromise(posts);
2020-01-14 10:26:50 -05:00
// happy goodbye
console.log('\nAll done!');
2025-02-07 17:49:31 -05:00
console.log('Look for your output files in: ' + path.resolve(shared.config.output));
2025-01-25 10:27:24 -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);
});