def npm(b, r):
    logging.info('searching for npm packages')

    # Precompile a pattern for parsing the output of `{pear,pecl} list`.
    pattern = re.compile(r'^\S+ (\S+)@(\S+)$')

    try:
        p = subprocess.Popen(['npm', 'ls', '-g'],
                             close_fds=True,
                             stdout=subprocess.PIPE)
        for line in p.stdout:
            match = pattern.match(line.rstrip())
            if match is None:
                continue
            package, version = match.group(1), match.group(2)
            if not r.ignore_package('nodejs', package):
                b.add_package('nodejs', package, version)
    except __HOLE__:
        pass
dataset/ETHPy150Open devstructure/blueprint/blueprint/backend/npm.py/npm