Browse Source

show errors in spinner

master
Feross Aboukhadijeh 7 years ago
parent
commit
a58c5ebe3e
  1. 22
      cmd.js
  2. 1
      package.json

22
cmd.js

@ -13,7 +13,6 @@ const registryUrl = require('registry-url')
const stripAnsi = require('strip-ansi')
const textTable = require('text-table')
const { promisify } = require('util')
const { stripIndent } = require('common-tags')
const thanks = require('./')
@ -23,14 +22,21 @@ const setTimeoutAsync = promisify(setTimeout)
const DOWNLOADS_URL = 'https://api.npmjs.org/downloads/point/last-month/'
const DOWNLOADS_URL_LIMIT = 128
const readPackageTreeAsync = pify(readPackageTree)
init().catch(handleError)
const spinner = ora({
spinner: 'moon',
text: chalk`Getting ready to {cyan give thanks} to {magenta maintainers}...`
}).start()
init()
.catch(function (err) {
spinner.fail(`Error: ${err.message}\n`)
console.error(
chalk`{cyan Found a bug?} Open an issue at {magenta https://github.com/feross/thanks}\n`
)
console.error(err.stack)
process.exitCode = 1
})
async function init () {
const client = createRegistryClient()
@ -60,6 +66,8 @@ async function init () {
// Author name -> list of packages, ordered by download count
const authorInfos = computeAuthorInfos(allPkgs, downloadCounts)
// TODO: compute list of **projects** seeking donations
const donateLinks = []
const rows = Object.keys(authorInfos)
@ -196,9 +204,3 @@ function computeAuthorInfos (pkgs, downloadCounts) {
return authorInfos
}
function handleError (err) {
console.error(`thanks: Error: ${err.message}`)
console.error(err.stack)
process.exitCode = 1
}

1
package.json

@ -16,6 +16,7 @@
"got": "^8.0.3",
"minimist": "^1.2.0",
"npm-registry-client": "^8.5.0",
"opn": "^5.2.0",
"ora": "^1.4.0",
"pify": "^3.0.0",
"pkg-dir": "^2.0.0",

Loading…
Cancel
Save