Add support for NPM Registry
This commit is contained in:
parent
3dce06ca21
commit
49ec750772
|
@ -159,6 +159,13 @@ Check `RubyGems <https://rubygems.org/>`_ for updates.
|
|||
gems
|
||||
The name used on RubyGems, e.g. ``sass``.
|
||||
|
||||
Check NPM Registry
|
||||
----------
|
||||
Check `NPM Registry <https://registry.npmjs.org/>`_ for updates.
|
||||
|
||||
npm
|
||||
The name used on NPM Registry, e.g. ``coffee-script``.
|
||||
|
||||
Check Local Pacman Database
|
||||
---------------------------
|
||||
This is used when you run ``nvchecker`` on an Arch Linux system and the program always keeps up with a package in your configured repositories for `Pacman`_.
|
||||
|
|
|
@ -5,6 +5,7 @@ logger = logging.getLogger(__name__)
|
|||
handler_precedence = (
|
||||
'github', 'gitcafe', 'aur', 'pypi', 'archpkg', 'gems', 'pacman',
|
||||
'cmd', 'bitbucket', 'gcode_hg', 'gcode_svn', 'regex', 'manual', 'vcs',
|
||||
'npm',
|
||||
)
|
||||
|
||||
def get_version(name, conf, callback):
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
import json
|
||||
from functools import partial
|
||||
|
||||
from tornado.httpclient import AsyncHTTPClient
|
||||
|
||||
NPM_URL = 'https://registry.npmjs.org/%s'
|
||||
|
||||
def get_version(name, conf, callback):
|
||||
repo = conf.get('npm') or name
|
||||
url = NPM_URL % repo
|
||||
AsyncHTTPClient().fetch(url, user_agent='lilydjwg/nvchecker',
|
||||
callback=partial(_npm_done, name, callback))
|
||||
|
||||
def _npm_done(name, callback, res):
|
||||
data = json.loads(res.body.decode('utf-8'))
|
||||
version = data['dist-tags']['latest']
|
||||
callback(name, version)
|
Loading…
Reference in New Issue