Compare commits

...

2 commits

Author SHA1 Message Date
Glenn Y. Rolland b60f030824 fix: make unit tests work with CODE_PRELOADER_DETECT=no
All checks were successful
continuous-integration/drone/push Build is passing
2024-01-05 11:48:12 +01:00
Glenn Y. Rolland bde15cfd25 feat: env CODE_PRELOADER_DETECT=no disables config auto-detect 2024-01-05 11:47:52 +01:00
5 changed files with 25 additions and 20 deletions

View file

@ -12,10 +12,11 @@ ignore_list:
- complex/ignore2
# Path to the output file (if null, output to STDOUT)
output_file_path: complex_output.txt
output_path: complex_output.txt
# Optional: Path to a file containing the header prompt
header_prompt_file_path: null
prompt:
# Optional: Path to a file containing the header prompt
header_path: null
# Optional: Path to a file containing the footer prompt
footer_prompt_file_path: null
# Optional: Path to a file containing the footer prompt
footer_path: null

View file

@ -11,10 +11,11 @@ ignore_list:
- simple/ignore
# Path to the output file (if null, output to STDOUT)
output_file_path: simple_output.txt
output_path: simple_output.txt
# Optional: Path to a file containing the header prompt
header_prompt_file_path: null
prompt:
# Optional: Path to a file containing the header prompt
header_path: null
# Optional: Path to a file containing the footer prompt
footer_prompt_file_path: null
# Optional: Path to a file containing the footer prompt
footer_path: null

View file

@ -50,7 +50,7 @@ describe CodePreloader::Config do
config.subcommand.should eq(Config::Subcommand::Pack)
config.pack_options.should be_truthy
config.pack_options.try do |opts|
opts.repository_path_list.should eq ["path/to/repo1", "path/to/repo2"]
opts.source_list.should eq ["path/to/repo1", "path/to/repo2"]
end
end
@ -72,7 +72,7 @@ describe CodePreloader::Config do
config.subcommand.should eq(Config::Subcommand::Pack)
config.pack_options.should be_truthy
config.pack_options.try do |opts|
opts.output_file_path.should eq "output.txt"
opts.output_path.should eq "output.txt"
end
end
@ -88,9 +88,9 @@ describe CodePreloader::Config do
# Assuming the simple_config.yml has specific settings
config.pack_options.should be_truthy
config.pack_options.try do |opts|
opts.repository_path_list.should eq ["path/to/repo"]
opts.source_list.should eq ["path/to/repo"]
opts.ignore_list.should eq ["simple/ignore"]
opts.output_file_path.should eq "simple_output.txt"
opts.output_path.should eq "simple_output.txt"
end
end
@ -103,9 +103,9 @@ describe CodePreloader::Config do
# Assuming the complex_config.yml has specific settings
config.pack_options.should be_truthy
config.pack_options.try do |opts|
opts.repository_path_list.should eq [repo_path]
opts.source_list.should eq [repo_path]
opts.ignore_list.should eq ["complex/ignore1", "complex/ignore2"]
opts.output_file_path.should eq "complex_output.txt"
opts.output_path.should eq "complex_output.txt"
end
end

View file

@ -1,4 +1,5 @@
require "spec"
# require "../src/"
ENV["CODE_PRELOADER_DETECT"] = "no"

View file

@ -86,8 +86,10 @@ module CodePreloader
def parse_pack_options(parser)
@pack_options = PackOptions.new
config_file = detect_config_file
config_file.try { |path| load_pack_config(path) }
unless ENV["CODE_PRELOADER_DETECT"]? =~ /(no|false|0)/i
config_file = detect_config_file
config_file.try { |path| load_pack_config(path) }
end
parser.banner = [
"Usage: code-preloader pack [options] DIR ...\n",
@ -99,7 +101,7 @@ module CodePreloader
parser.on(
"-c FILE",
"--config=FILE",
"Load parameters from FILE\n(default: \".code_preload.yml\", if present)"
"Load parameters from FILE\n(default: autodetect)"
) do |config_file|
@pack_options.try { |opt| load_pack_config(config_file) }
end