Ghost/ghost/substack-ghost-csv-converter/bin/index.js
Naz Gargol d0f8cd9e78 Added Substack to Ghost CSV converter package (#121)
refs https://github.com/TryGhost/Ghost/pull/11539

- The script helps to migrate CSV exports from Substack to Ghost-compatible ones
2020-02-04 14:03:29 +08:00

34 lines
911 B
JavaScript

#!/usr/bin/env node
const prettyCLI = require('@tryghost/pretty-cli');
const ui = require('@tryghost/pretty-cli').ui;
const chalk = require('chalk');
const converter = require('../');
prettyCLI
.configure({
name: 'subghost'
})
.positional('<source>', {
paramsDesc: 'Substack CSV file path',
mustExist: true
})
.positional('<dest>', {
paramsDesc: 'Ghost CSV destination file path. Will write to source if not present',
mustExist: false
})
.parseAndExit()
.then((argv) => {
const dest = argv.dest || argv.source;
ui.log(`Converting Substack CSV file...`);
return converter(argv.source, dest).then(() => {
ui.log(`Conversion finished. File written to: ${chalk.cyan(dest)}`);
process.exit(0);
}).catch((e) => {
ui.log(e);
process.exit(1);
});
});