feat(cache): Allow add to accept multiple specs · npm/cli@701627c (original) (raw)

`` @@ -86,32 +86,30 @@ with --force.`)

``

86

86

`return rimraf(cachePath)

`

87

87

`}

`

88

88

``

89

``

`-

// npm cache add

`

90

``

`-

// npm cache add

`

91

``

`-

// npm cache add

`

92

``

`-

// npm cache add

`

``

89

`+

// npm cache add ...

`

``

90

`+

// npm cache add ...

`

``

91

`+

// npm cache add ...

`

``

92

`+

// npm cache add ...

`

93

93

`async add (args) {

`

94

94

`const usage = 'Usage:\n' +

`

95

``

`-

' npm cache add \n' +

`

96

``

`-

' npm cache add @\n' +

`

97

``

`-

' npm cache add \n' +

`

98

``

`-

' npm cache add \n'

`

``

95

`+

' npm cache add ...\n' +

`

``

96

`+

' npm cache add @...\n' +

`

``

97

`+

' npm cache add ...\n' +

`

``

98

`+

' npm cache add ...\n'

`

99

99

`log.silly('cache add', 'args', args)

`

100

``

`-

const spec = args[0] && args[0] +

`

101

``

`` -

(args[1] === undefined || args[1] === null ? '' : @${args[1]})

``

102

``

-

103

``

`-

if (!spec)

`

``

100

`+

if (args.length === 0)

`

104

101

`throw Object.assign(new Error(usage), { code: 'EUSAGE' })

`

105

102

``

106

``

`-

log.silly('cache add', 'spec', spec)

`

107

``

-

108

``

`-

// we ask pacote for the thing, and then just throw the data

`

109

``

`-

// away so that it tee-pipes it into the cache like it does

`

110

``

`-

// for a normal request.

`

111

``

`-

await pacote.tarball.stream(spec, stream => {

`

112

``

`-

stream.resume()

`

113

``

`-

return stream.promise()

`

114

``

`-

}, this.npm.flatOptions)

`

``

103

`+

return Promise.all(args.map(spec => {

`

``

104

`+

log.silly('cache add', 'spec', spec)

`

``

105

`+

// we ask pacote for the thing, and then just throw the data

`

``

106

`+

// away so that it tee-pipes it into the cache like it does

`

``

107

`+

// for a normal request.

`

``

108

`+

return pacote.tarball.stream(spec, stream => {

`

``

109

`+

stream.resume()

`

``

110

`+

return stream.promise()

`

``

111

`+

}, this.npm.flatOptions)

`

``

112

`+

}))

`

115

113

`}

`

116

114

``

117

115

`async verify () {

`