1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | 'use strict';
|
9 |
|
10 | var utils = require('./utils');
|
11 |
|
12 | module.exports = function get(repos, cb) {
|
13 | if (typeof cb !== 'function') {
|
14 | throw new TypeError('expected callback to be a function');
|
15 | }
|
16 |
|
17 | if (typeof repos === 'string') {
|
18 | repos = [repos];
|
19 | }
|
20 |
|
21 | if (!Array.isArray(repos)) {
|
22 | throw new TypeError('expected the first argument to be a string or array');
|
23 | }
|
24 |
|
25 | var i = 0;
|
26 | utils.async.map(repos, utils.pkg, function(err, res) {
|
27 | var name = repos[i];
|
28 | i++;
|
29 |
|
30 | if (err) {
|
31 | if (err.message !== 'document not found') {
|
32 | cb(err);
|
33 | return;
|
34 | }
|
35 | console.error('npm package "%s" does not exist', name);
|
36 | res = res.filter(Boolean);
|
37 | }
|
38 | cb(null, res);
|
39 | });
|
40 | };
|