Sha256: e59a5c3e49023234b5be231fe1af43c7b39599315188477a85f8d4829604da48
Contents?: true
Size: 902 Bytes
Versions: 42
Compression:
Stored size: 902 Bytes
Contents
# frozen_string_literal: true module ShopifyCLI module Theme module Filter module PathMatcher def regex_match?(regex, path) regex.match?(path) rescue StandardError false end def glob_match?(glob, path) !!::File.fnmatch?(glob, path) end def regex?(pattern) pattern.start_with?("/") && pattern.end_with?("/") end def as_regex(pattern) Regexp.new(pattern.gsub(%r{^\/|\/$}, "")) end def as_glob(pattern) # if specifying a directory, match everything below it pattern += "*" if pattern.end_with?("/") # The pattern will be scoped to root directory, so it should match anything # within that space pattern.prepend("*") unless pattern.start_with?("*") pattern end end end end end
Version data entries
42 entries across 42 versions & 1 rubygems