From dbb8816b0c5d7647020b64fe5e1889b22c42d388 Mon Sep 17 00:00:00 2001 From: Danny Ben Shitrit Date: Tue, 26 Dec 2023 05:55:22 +0000 Subject: [PATCH 1/2] - Avoid rendering `inspect_args()` when generating for production env --- lib/bashly/commands/generate.rb | 4 ++-- lib/bashly/views/command/master_script.gtx | 2 +- spec/bashly/commands/generate_spec.rb | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/bashly/commands/generate.rb b/lib/bashly/commands/generate.rb index e0c042c6..5553bc2a 100644 --- a/lib/bashly/commands/generate.rb +++ b/lib/bashly/commands/generate.rb @@ -16,8 +16,8 @@ class Generate < Base option '-e --env ENV', <<~HELP Force the generation environment: - - production generate a smaller script, without file markers - - development generate with file markers + - development default script output + - production remove file marker comments and development functions HELP example 'bashly generate --force' diff --git a/lib/bashly/views/command/master_script.gtx b/lib/bashly/views/command/master_script.gtx index 4bfe192f..f3fc6b52 100644 --- a/lib/bashly/views/command/master_script.gtx +++ b/lib/bashly/views/command/master_script.gtx @@ -4,7 +4,7 @@ = render :version_command = render :usage = render :normalize_input -= render :inspect_args += render :inspect_args unless Settings.production? = render :user_lib if user_lib.any? = render :command_functions = render :parse_requirements diff --git a/spec/bashly/commands/generate_spec.rb b/spec/bashly/commands/generate_spec.rb index 78c3ef90..c0f3795e 100644 --- a/spec/bashly/commands/generate_spec.rb +++ b/spec/bashly/commands/generate_spec.rb @@ -28,10 +28,11 @@ before { Settings.env = :production } after { Settings.env = nil } - it 'generates a script without view markers' do + it 'generates a script without view markers or inspect_args function' do expect { subject.execute %w[generate] }.to output_approval('cli/generate/production-env-var') expect(File).to exist(cli_script) expect(cli_script_content).not_to include '# :' + expect(cli_script_content).not_to include 'inspect_args()' end end From 10899cf641b62dad04a4f618eb4e36585f5236b3 Mon Sep 17 00:00:00 2001 From: Danny Ben Shitrit Date: Tue, 26 Dec 2023 06:03:44 +0000 Subject: [PATCH 2/2] approvals --- spec/approvals/cli/generate/help | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/approvals/cli/generate/help b/spec/approvals/cli/generate/help index 46799b02..5a930dff 100644 --- a/spec/approvals/cli/generate/help +++ b/spec/approvals/cli/generate/help @@ -23,8 +23,8 @@ Options: -e --env ENV Force the generation environment: - - production generate a smaller script, without file markers - - development generate with file markers + - development default script output + - production remove file marker comments and development functions -h --help Show this help