Skip to content

Commit

Permalink
Merge pull request #142 from boltops-tools/builder-skip
Browse files Browse the repository at this point in the history
improve builder skip check: check if its a dir
  • Loading branch information
tongueroo authored Oct 2, 2021
2 parents 365a093 + 91d93ad commit a421554
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
8 changes: 1 addition & 7 deletions lib/terraspace/compiler/builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,7 @@ def with_path(path)
end

def skip?(src_path)
return true unless File.file?(src_path)
# certain folders will be skipped
src_path.include?("#{@mod.root}/config/args") ||
src_path.include?("#{@mod.root}/config/helpers") ||
src_path.include?("#{@mod.root}/config/hooks") ||
src_path.include?("#{@mod.root}/test") ||
src_path.include?("#{@mod.root}/tfvars")
Skip.new(@mod, src_path).check?
end

def search(expr)
Expand Down
28 changes: 28 additions & 0 deletions lib/terraspace/compiler/builder/skip.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
class Terraspace::Compiler::Builder
class Skip
def initialize(mod, src_path)
@mod, @src_path = mod, src_path
end

def check?
return true unless File.file?(@src_path)

# skip certain folders
check_dirs?(
"config/args",
"config/helpers",
"config/hooks",
"test",
"tfvars",
)
end

def check_dirs?(*names)
names.flatten.detect { |name| check_dir?(name) }
end

def check_dir?(name)
@src_path.include?("#{@mod.root}/#{name}/")
end
end
end

0 comments on commit a421554

Please # to comment.