Skip to content

Commit d663616

Browse files
authored
Merge pull request #686 from bashly-framework/update/var-order
Move global variable declarations after environment variable declarations
2 parents b95a0a9 + 14830e0 commit d663616

File tree

7 files changed

+36
-1
lines changed

7 files changed

+36
-1
lines changed

lib/bashly/views/command/initialize.gtx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
if root_command?
88
>
9-
= render(:variables).indent(2)
109
= render(:environment_variables_default).indent 2
10+
= render(:variables).indent(2)
1111
end
1212

1313
if user_file_exist?('initialize')

spec/approvals/fixtures/var-order

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
+ bundle exec bashly generate
2+
creating user files in src
3+
skipped src/root_command.sh (exists)
4+
created ./cli
5+
run ./cli --help to test your bash script
6+
+ ./cli
7+
args: none
8+
9+
environment variables:
10+
- $CLI_CONFIG_FILE = config.yaml
11+
$config_file == $CLI_CONFIG_FILE == config.yaml
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
cli
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
This fixture ensures that environment variables are declared and populated
2+
begore variables defined in bashly.yml, to allow using the values from them
3+
in the variables.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: cli
2+
help: Ensure env var / var order
3+
version: 0.1.0
4+
5+
environment_variables:
6+
- name: cli_config_file
7+
help: Path to config file
8+
default: config.yaml
9+
10+
variables:
11+
- name: config_file
12+
value: $CLI_CONFIG_FILE
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
inspect_args
2+
echo "\$config_file == \$CLI_CONFIG_FILE == $config_file"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env bash
2+
3+
set -x
4+
5+
bundle exec bashly generate
6+
./cli

0 commit comments

Comments
 (0)