Skip to content

Commit

Permalink
implement spinner for better feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
simonhaenisch committed Sep 15, 2018
1 parent 66914fd commit 2221196
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 18 deletions.
13 changes: 8 additions & 5 deletions index.js
Expand Up @@ -6,6 +6,7 @@
const path = require('path');
const arg = require('arg');
const chalk = require('chalk');
const ora = require('ora');
const grayMatter = require('gray-matter');

// --
Expand Down Expand Up @@ -50,14 +51,16 @@ async function main(args, config) {

if (args['--version']) {
console.log(require('./package').version);
return 0;
return;
}

if (args['--help'] || mdFilePath === undefined) {
help();
return 0;
return;
}

const spinner = ora({ color: 'white', text: `generating PDF from ${chalk.underline(mdFilePath)}` }).start();

if (args['--html-pdf-options']) {
console.warn(
[
Expand Down Expand Up @@ -118,10 +121,10 @@ async function main(args, config) {
const pdf = await writePdf(mdFilePath, outputPath, html, config);

if (pdf.filename) {
console.log(`${chalk.green('PDF created successfully:')} ${chalk.bold(pdf.filename)}`);
spinner.succeed(`PDF created successfully: ${chalk.underline(pdf.filename)}`);
} else {
spinner.fail('Failed to created PDF');
}

return 0;
}

// --
Expand Down
51 changes: 38 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Expand Up @@ -34,6 +34,7 @@
"highlight.js": "9.12.0",
"iconv-lite": "0.4.24",
"marked": "0.5.0",
"ora": "3.0.0",
"puppeteer": "1.8.0",
"serve-handler": "5.0.2"
},
Expand Down

0 comments on commit 2221196

Please sign in to comment.