Skip to content

Commit

Permalink
fix: properly exclude files
Browse files Browse the repository at this point in the history
  • Loading branch information
ronaldtse committed Jun 12, 2024
1 parent 5a2e604 commit 0c93b85
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/poepod/cli.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

require "thor"
require "poepod/processor"
require_relative "processor"

module Poepod
class Cli < Thor
Expand Down
9 changes: 5 additions & 4 deletions lib/poepod/processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
module Poepod
class Processor
EXCLUDE_DEFAULT = [
"node_modules/", ".git/", ".gitignore", ".DS_Store",
"*.jpg", "*.jpeg", "*.png", "*.svg", "*.gif",
"*.exe", "*.dll", "*.so", "*.bin", "*.o", "*.a"
/node_modules\//, /.git\//, /.gitignore$/, /.DS_Store$/,
/.jpg$/, /.jpeg$/, /.png/, /.svg$/, /.gif$/,
/.exe$/, /.dll$/, /.so$/, /.bin$/, /.o$/, /.a$/, /.gem$/, /.cap$/,
/.zip$/,
].freeze

def initialize(config_file = nil)
Expand All @@ -35,7 +36,7 @@ def process_file(file_path)

def gather_files(directory_path, exclude)
exclude += @config["exclude"] if @config["exclude"]
exclude_pattern = Regexp.union(exclude.map { |ex| Regexp.escape(ex) })
exclude_pattern = Regexp.union(exclude.map { |ex| Regexp.new(ex) })

Dir.glob("#{directory_path}/**/*").reject do |file_path|
File.directory?(file_path) || file_path.match?(exclude_pattern)
Expand Down

0 comments on commit 0c93b85

Please sign in to comment.