import * as yargs from 'yargs'; import * as fs from 'fs'; import { blue, red } from 'chalk'; import { Publisher } from './publisher'; import { parseYAML } from './parser'; /** * @module quietmath/minerva-publish */ if(yargs.argv.f === undefined || (yargs.argv.f as string).trim() === '') { console.error(red('Error: No file specified with the `--f` command line switch.')); } else { console.info(blue(`Reading file ${ yargs.argv.f }`)); const data: string = fs.readFileSync(yargs.argv.f as string, 'utf-8'); if(data != null) { console.info(blue(`Parsing file ${ yargs.argv.f }`)); const pub: Publisher = new Publisher(parseYAML(data)); pub.sanity() .then((): void => { pub.clean(); pub.outline(); pub.toc(); pub.feeds(); pub.lists(); pub.view(); pub.static(); pub.copy(); }).catch((err: any): void => { console.error(red(`Could not publish files: ${ err }`)); }); } }