UNPKG

853 BJavaScriptView Raw
1require('lazy-ass');
2var check = require('check-more-types');
3var Promise = require('bluebird');
4var R = require('ramda');
5var packageField = Promise.promisify(require('package-json').field);
6var utils = require('./utils');
7
8var log = console.log.bind(console);
9var debug = require('debug')('load');
10
11// resolves with the github url for the given NPM package name
12function packageRepo(name) {
13 la(check.unemptyString(name), 'missing package name', name);
14
15 if (utils.isGithubName(name)) {
16 return Promise.resolve(utils.parseGithubName(name));
17 }
18
19 return packageField(name, 'repository')
20 .tap(utils.verifyGithub)
21 .then(R.prop('url'))
22 .then(utils.parseGithubUrl);
23}
24
25module.exports = packageRepo;
26
27if (!module.parent) {
28 var name = 'next-update';
29 log('getting repo info for package %s', name);
30 packageRepo(name)
31 .then(log);
32}