diff options
author | Myles Borins <mylesborins@github.com> | 2020-10-02 17:52:19 -0400 |
---|---|---|
committer | Myles Borins <mylesborins@github.com> | 2020-10-07 09:59:49 -0400 |
commit | 2e545249557c265f7d5f338cc3a382985211603c (patch) | |
tree | a18ca49252a58cc5a80cd438a020a99bf48a8d23 /deps/npm/lib/star.js | |
parent | 14699846452e627f97dedb85991eea67d932a79d (diff) | |
download | node-new-2e545249557c265f7d5f338cc3a382985211603c.tar.gz |
deps: update npm to 7.0.0-rc.3
PR-URL: https://github.com/nodejs/node/pull/35474
Reviewed-By: Ruy Adorno <ruyadorno@github.com>
Reviewed-By: Ujjwal Sharma <ryzokuken@disroot.org>
Reviewed-By: Ben Coe <bencoe@gmail.com>
Reviewed-By: Geoffrey Booth <webmaster@geoffreybooth.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Shelley Vohr <codebytere@gmail.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'deps/npm/lib/star.js')
-rw-r--r-- | deps/npm/lib/star.js | 56 |
1 files changed, 26 insertions, 30 deletions
diff --git a/deps/npm/lib/star.js b/deps/npm/lib/star.js index 44a762b15c..04b8285fb0 100644 --- a/deps/npm/lib/star.js +++ b/deps/npm/lib/star.js @@ -1,20 +1,12 @@ 'use strict' -const BB = require('bluebird') - -const fetch = require('libnpm/fetch') -const figgyPudding = require('figgy-pudding') +const fetch = require('npm-registry-fetch') const log = require('npmlog') -const npa = require('libnpm/parse-arg') +const npa = require('npm-package-arg') const npm = require('./npm.js') -const npmConfig = require('./config/figgy-config.js') const output = require('./utils/output.js') const usage = require('./utils/usage.js') -const whoami = require('./whoami.js') - -const StarConfig = figgyPudding({ - 'unicode': {} -}) +const getItentity = require('./utils/get-identity') star.usage = usage( 'star', @@ -30,21 +22,24 @@ star.completion = function (opts, cb) { module.exports = star function star (args, cb) { - const opts = StarConfig(npmConfig()) - return BB.try(() => { + 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 - return BB.map(args.map(npa), pkg => { - return BB.all([ - whoami([pkg], true, () => {}), - fetch.json(pkg.escapedName, opts.concat({ + // 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), + fetch.json(pkg.escapedName, { + ...opts, spec: pkg, - query: {write: true}, - 'prefer-online': true - })) + query: { write: true }, + preferOnline: true + }) ]).then(([username, fullData]) => { if (!username) { throw new Error('You need to be logged in!') } const body = { @@ -53,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,16 +57,17 @@ function star (args, cb) { log.info('star', 'unstarring', body._id) log.verbose('star', 'unstarring', body) } - return fetch.json(pkg.escapedName, opts.concat({ + return fetch.json(pkg.escapedName, { + ...opts, spec: pkg, method: 'PUT', body - })) + }) }).then(data => { - output(s + ' ' + pkg.name) + output(show + ' ' + pkg.name) log.verbose('star', data) return data }) - }) - }).nodeify(cb) + })) + }).then(() => cb(), cb) } |