diff --git a/schemas/settings.json b/schemas/settings.json index 9d0e57837..d6477f188 100644 --- a/schemas/settings.json +++ b/schemas/settings.json @@ -201,6 +201,18 @@ ], "default": "always" }, + "enable_sourcing": { + "title": "enable_sourcing", + "description": "Whether to wrap the script execution in a condition that checks if the script is sourced\nhttps://bashly.dannyb.co/usage/settings/#enable_sourcing", + "type": "string", + "enum": [ + "development", + "production", + "always", + "never" + ], + "default": "development" + }, "partials_extension": { "title": "partials extension", "description": "The extension to use when reading/writing partial script snippets\nhttps://bashly.dannyb.co/usage/settings/#partials_extension", diff --git a/spec/approvals/cli/preview/no-args b/spec/approvals/cli/preview/no-args index 3b5dfcbf4..d42463e5d 100644 --- a/spec/approvals/cli/preview/no-args +++ b/spec/approvals/cli/preview/no-args @@ -1,3 +1,3 @@ #!/usr/bin/env bash ... -run "$@" +run "$@" \ No newline at end of file diff --git a/spec/bashly/commands/preview_spec.rb b/spec/bashly/commands/preview_spec.rb index 2a0db8623..89f43d10b 100644 --- a/spec/bashly/commands/preview_spec.rb +++ b/spec/bashly/commands/preview_spec.rb @@ -17,7 +17,7 @@ it 'prints the generated cli script' do expect { subject.execute %w[preview] }.to output_approval('cli/preview/no-args') - .except(/env bash\n.*\nrun "\$@"/m, "env bash\n...\nrun \"$@\"") + .except(/env bash\n.*\n\s*run "\$@"\n.*/m, "env bash\n...\nrun \"$@\"") end end end diff --git a/spec/bashly/script/wrapper_spec.rb b/spec/bashly/script/wrapper_spec.rb index c7cd79887..74484a430 100644 --- a/spec/bashly/script/wrapper_spec.rb +++ b/spec/bashly/script/wrapper_spec.rb @@ -11,7 +11,7 @@ lines = subject.code.split "\n" expect(lines[0..13].join("\n")).to match_approval('script/wrapper/code') .except(/\d+\.\d+\.\d+(\.rc\d)?/) - expect(lines[-1]).to eq 'run "$@"' + expect(lines[-2]).to eq ' run "$@"' end end diff --git a/support/schema/settings.yml b/support/schema/settings.yml index 66bd91d74..f7bb33d01 100644 --- a/support/schema/settings.yml +++ b/support/schema/settings.yml @@ -173,6 +173,14 @@ properties: type: string enum: *feature_toggles default: always + enable_sourcing: + title: enable_sourcing + description: |- + Whether to wrap the script execution in a condition that checks if the script is sourced + https://bashly.dannyb.co/usage/settings/#enable_sourcing + type: string + enum: *feature_toggles + default: development partials_extension: title: partials extension description: |-