UNPKG

815 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);
9
10// resolves with the github url for the given NPM package name
11function packageRepo(name) {
12 la(check.unemptyString(name), 'missing package name', name);
13
14 if (utils.isGithubName(name)) {
15 return Promise.resolve(utils.parseGithubName(name));
16 }
17
18 return packageField(name, 'repository')
19 .tap(utils.verifyGithub)
20 .then(R.prop('url'))
21 .then(utils.parseGithubUrl);
22}
23
24module.exports = packageRepo;
25
26if (!module.parent) {
27 var name = 'next-update';
28 log('getting repo info for package %s', name);
29 packageRepo(name)
30 .then(log);
31}