Sha256: 3830e67977155b2d534c02125ea0f69b2243a5fb1645b981bec8e8f262f3a0e8
Contents?: true
Size: 1.38 KB
Versions: 20
Compression:
Stored size: 1.38 KB
Contents
# frozen_string_literal: true require "pathname" require "dependabot/file_fetchers/dotnet/nuget" module Dependabot module FileFetchers module Dotnet class Nuget class SlnProjectPathsFinder PROJECT_PATH_REGEX = /(?<=["'])[^"']*?\.(?:vb|cs|fs)proj(?=["'])/.freeze def initialize(sln_file:) @sln_file = sln_file end def project_paths paths = [] sln_file_lines = sln_file.content.lines sln_file_lines.each_with_index do |line, index| next unless line.match?(/^\s*Project/) # Don't know how to handle multi-line project declarations yet next unless sln_file_lines[index + 1]&.match?(/^\s*EndProject/) path = line.split('"')[5] path = path.tr("\\", "/") # If the path doesn't have an extension it's probably a directory next unless path.match?(/\.[a-z]{2}proj$/) path = File.join(current_dir, path) unless current_dir.nil? paths << Pathname.new(path).cleanpath.to_path end paths end private attr_reader :sln_file def current_dir parts = sln_file.name.split("/")[0..-2] return if parts.empty? parts.join("/") end end end end end end
Version data entries
20 entries across 20 versions & 1 rubygems