diff options
author | isaacs <i@izs.me> | 2020-03-05 09:32:08 +0300 |
---|---|---|
committer | isaacs <i@izs.me> | 2020-05-08 04:12:27 +0300 |
commit | 77c613d50718eab04b458e2d96485c30c2bf0bef (patch) | |
tree | 5757d97c1de49456668629642d53b763c82c9740 /lib | |
parent | b1d6cdd55ddc843ac0268c461cecf0a47f3d2295 (diff) |
de-terse the star command output picture logic
Diffstat (limited to 'lib')
-rw-r--r-- | lib/star.js | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/star.js b/lib/star.js index eec948291..b9beda0be 100644 --- a/lib/star.js +++ b/lib/star.js @@ -25,10 +25,12 @@ function star (args, cb) { const opts = npm.flatOptions return Promise.resolve().then(() => { if (!args.length) throw new Error(star.usage) - let s = opts.unicode ? '\u2605 ' : '(*)' - const u = opts.unicode ? '\u2606 ' : '( )' - const using = !(npm.command.match(/^un/)) - if (!using) s = u + // if we're unstarring, then show an empty star image + // otherwise, show the full star image + const unstar = /^un/.test(npm.command) + const full = opts.unicode ? '\u2605 ' : '(*)' + const empty = opts.unicode ? '\u2606 ' : '( )' + const show = unstar ? empty : full return Promise.all(args.map(npa).map(pkg => { return Promise.all([ getItentity(opts), @@ -46,7 +48,7 @@ function star (args, cb) { users: fullData.users || {} } - if (using) { + if (!unstar) { log.info('star', 'starring', body._id) body.users[username] = true log.verbose('star', 'starring', body) @@ -62,7 +64,7 @@ function star (args, cb) { body }) }).then(data => { - output(s + ' ' + pkg.name) + output(show + ' ' + pkg.name) log.verbose('star', data) return data }) |