MCPcopy Create free account
hub / github.com/aboutcode-org/scancode-toolkit / walk_npm

Method walk_npm

src/packagedcode/npm.py:289–307  ·  view source on GitHub ↗

Walk the ``codebase`` Codebase top-down, breadth-first starting from the ``resource`` Resource. Skip a first level child directory named "node_modules": this avoids reporting nested vendored packages as being part of their parent. Instead they will be report

(cls, resource, codebase, depth=0)

Source from the content-addressed store, hash-verified

287
288 @classmethod
289 def walk_npm(cls, resource, codebase, depth=0):
290 """
291 Walk the ``codebase`` Codebase top-down, breadth-first starting from the
292 ``resource`` Resource.
293
294 Skip a first level child directory named "node_modules": this avoids
295 reporting nested vendored packages as being part of their parent.
296 Instead they will be reported on their own.
297 """
298 for child in resource.children(codebase):
299 if depth == 0 and child.name == 'node_modules':
300 continue
301
302 yield child
303
304 if child.is_dir:
305 depth += 1
306 for subchild in cls.walk_npm(child, codebase, depth=depth):
307 yield subchild
308
309 @classmethod
310 def update_dependencies_by_purl(

Callers 2

assembleMethod · 0.80

Calls 1

childrenMethod · 0.45

Tested by

no test coverage detected