'Resolve hits from a CommonJS require() invocation'

def _hits_from_commonjs_require(self, requirename, scoperef):

    requirename += '.js'
    from codeintel2.database.langlib import LangDirsLib
    from codeintel2.database.multilanglib import MultiLangDirsLib
    from codeintel2.database.catalog import CatalogLib
    hits = []
    for lib in self.libs:
        blobs = None
        if isinstance(lib, (LangDirsLib, MultiLangDirsLib)):
            blobs = lib.blobs_with_basename(requirename, ctlr=self.ctlr)
        elif isinstance(lib, CatalogLib):
            blob = lib.get_blob(requirename)
            if (blob is not None):
                blobs = [blob]
        for blob in (blobs or []):
            exports = blob.names.get('exports')
            if ((exports is not None) and (exports.tag == 'variable')):
                hits += self._hits_from_variable_type_inference(exports, [blob, ['exports']])
            else:
                self.log('Exported    exports    to    be    a    variable,    got    %r    instead', exports)
    return hits
