lib/licensed/sources/npm.rb in licensed-2.6.0 vs lib/licensed/sources/npm.rb in licensed-2.6.1

- old
+ new

@@ -7,15 +7,14 @@ def self.type "npm" end def enabled? - Licensed::Shell.tool_available?("npm") && File.exist?(@config.pwd.join("package.json")) + Licensed::Shell.tool_available?("npm") && File.exist?(config.pwd.join("package.json")) end def enumerate_dependencies - @yarn_lock_present = File.exist?(@config.pwd.join("yarn.lock")) packages.map do |name, package| path = package["path"] Dependency.new( name: name, version: package["version"], @@ -47,19 +46,24 @@ # Recursively parse dependency JSON data. Returns a hash mapping the # package name to it's metadata def recursive_dependencies(dependencies, result = {}) dependencies.each do |name, dependency| - next if @yarn_lock_present && dependency["missing"] + next if yarn_lock_present && dependency["missing"] (result[name] ||= []) << dependency recursive_dependencies(dependency["dependencies"] || {}, result) end result end # Returns the output from running `npm list` to get package metadata def package_metadata_command Licensed::Shell.execute("npm", "list", "--json", "--production", "--long", allow_failure: true) + end + + # Returns true if a yarn.lock file exists in the current directory + def yarn_lock_present + @yarn_lock_present ||= File.exist?(config.pwd.join("yarn.lock")) end end end end