diff --git a/cmd.js b/cmd.js index ba64d6a..2098d4a 100755 --- a/cmd.js +++ b/cmd.js @@ -12,12 +12,12 @@ const readPackageTree = require('read-package-tree') const registryAuthToken = require('registry-auth-token') const RegistryClient = require('npm-registry-client') // TODO: use npm-registry-fetch when done const registryUrl = require('registry-url') -const setTimeoutAsync = require('timeout-as-promise') const stripAnsi = require('strip-ansi') const termSize = require('term-size') const textTable = require('text-table') const { readFile } = require('fs') const { stripIndent } = require('common-tags') +const PromptConfirm = require('prompt-confirm') const thanks = require('./') @@ -55,13 +55,9 @@ init() async function init () { const argv = minimist(process.argv.slice(2), { - boolean: ['open'], alias: { h: 'help', v: 'version' - }, - default: { - open: true } }) const cwd = argv._[0] || process.cwd() @@ -97,7 +93,7 @@ function runVersion () { console.log(require('./package.json').version) } -async function runThanks (cwd, open) { +async function runThanks (cwd) { spinner = ora({ spinner: HEARTS_SPINNER, text: chalk`Getting ready to {cyan give thanks} to {magenta maintainers}...` @@ -163,8 +159,12 @@ async function runThanks (cwd, open) { printTable(authorsSeeking, pkgNamesSeeking, authorsPkgNames, directPkgNames) - if (donateLinks.length && open) { - openDonateLinks(donateLinks) + if (donateLinks.length) { + const prompt = new PromptConfirm( + chalk`Want to open these {cyan donate pages} in your {magenta web browser}? 🦄` + ) + const doOpen = await prompt.run() + if (doOpen) openDonateLinks(donateLinks) } } @@ -332,21 +332,10 @@ function listWithMaxLen (list, maxLen) { } async function openDonateLinks (donateLinks) { - const len = donateLinks.length - - const spinner = ora({ - spinner: HEARTS_SPINNER, - text: chalk`Opening {cyan ${len} donate pages} in your {magenta web browser}...` - }) - .start() - - await setTimeoutAsync(2000) - for (let donateLink of donateLinks) { await opn(donateLink, { wait: false }) } - - spinner.succeed(chalk`Opened {cyan ${len} donate pages} in your {magenta web browser} 💻`) + console.log(chalk`{bold.yellow You are awesome!} 🌟`) } async function readDirectPkgNames () { diff --git a/package.json b/package.json index b22986d..f5091c2 100644 --- a/package.json +++ b/package.json @@ -22,13 +22,13 @@ "pify": "^3.0.0", "pkg-dir": "^2.0.0", "pkg-up": "^2.0.0", + "prompt-confirm": "^1.2.0", "read-package-tree": "^5.1.6", "registry-auth-token": "^3.3.2", "registry-url": "^3.1.0", "strip-ansi": "^4.0.0", "term-size": "^1.2.0", - "text-table": "^0.2.0", - "timeout-as-promise": "^1.0.0" + "text-table": "^0.2.0" }, "devDependencies": { "standard": "*"