File tree Expand file tree Collapse file tree 18 files changed +105
-23
lines changed Expand file tree Collapse file tree 18 files changed +105
-23
lines changed Original file line number Diff line number Diff line change @@ -29,10 +29,16 @@ def header!
2929 if File . exist? custom_header_path
3030 File . read custom_header_path
3131 else
32- render ( 'header' )
32+ default_header
3333 end
3434 end
3535
36+ def default_header
37+ result = render ( 'header' )
38+ result += render ( 'bash3_bouncer' ) unless function_name
39+ result
40+ end
41+
3642 def body
3743 @body ||= command . render ( 'master_script' )
3844 end
Original file line number Diff line number Diff line change @@ -4,10 +4,5 @@ initialize() {
44 long_usage=''
55 set -e
66
7- if [[ "${BASH_VERSINFO:-0}" -lt 4 ]]; then
8- printf "<%= strings[:unsupported_bash_version] -%> \n"
9- exit 1
10- fi
11-
127<%= load_user_file("initialize.sh", placeholder: false).indent 2 %>
138}
Original file line number Diff line number Diff line change 1+ # :script.bash3_bouncer
2+ if [[ "${BASH_VERSINFO:-0}" -lt 4 ]]; then
3+ printf "<%= strings[:unsupported_bash_version] -%> \n"
4+ exit 1
5+ fi
Original file line number Diff line number Diff line change 11#! /usr/bin/env bash
22# This script was generated by bashly (https://github.com/DannyBen/bashly)
33# Modifying it manually is not recommended
4+
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ # This script was generated by bashly (https://github.com/DannyBen/bashly)
3+ # Modifying it manually is not recommended
4+
5+ # :script.wrapper
6+ function () {
7+
8+ # :command.version_command
9+ version_command () {
10+ echo " $version "
11+ }
Original file line number Diff line number Diff line change 1+ creating user files in src
2+ skipped src/initialize.sh (exists)
3+ skipped src/test_command.sh (exists)
4+ created ./cli
5+ run ./cli --help to test your bash script
6+ cli - Sample application
7+
8+ Usage:
9+ cli [command]
10+ cli [command] --help | -h
11+ cli --version | -v
12+
13+ Commands:
14+ test Run test
15+
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ # This script was generated by bashly (https://github.com/DannyBen/bashly)
3+ # Modifying it manually is not recommended
4+
5+ # :script.bash3_bouncer
6+ if [[ " ${BASH_VERSINFO:- 0} " -lt 4 ]]; then
7+ printf " bash version 4 or higher is required\n"
8+ exit 1
9+ fi
10+
11+ # :command.root_command
12+ root_command () {
13+ # :spec/tmp/src/root_command.sh
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ # This script was generated by bashly (https://github.com/DannyBen/bashly)
3+ # Modifying it manually is not recommended
4+
5+ # :script.wrapper
6+ my_super_function () {
7+ # :command.root_command
8+ root_command () {
9+ # :spec/tmp/src/root_command.sh
10+ echo " error: cannot load file"
11+ }
12+
13+ # :command.version_command
Original file line number Diff line number Diff line change 7575 expect ( success ) . to be true
7676 end
7777
78- it "generates the cli script wrapped in a function" do
78+ it "generates the cli script wrapped in a function without bash3 bouncer " do
7979 expect { subject . run %w[ generate -w function ] } . to output_approval ( 'cli/generate/wrap-function' )
8080 expect ( File ) . to exist ( cli_script )
8181 lines = File . readlines cli_script
82- expect ( lines [ 5 ] ) . to eq "function() { \n "
82+ expect ( lines [ 0 .. 10 ] . join ) . to match_approval ( 'cli/generate/wrap-script' )
8383 end
8484 end
8585
Original file line number Diff line number Diff line change 55 before { system "docker pull bash:3 >/dev/null" }
66
77 it "errors gracefully" do
8- command = "docker run --rm -v $PWD:/app bash:3 bash /app/download "
8+ command = "docker run --rm -v $PWD:/app bash:3 bash /app/cli "
99
10- Dir . chdir "examples/minimal " do
10+ Dir . chdir "spec/fixtures/workspaces/bash-3-syntax " do
1111 system "bashly generate 2>&1 >/dev/null"
1212 expect ( `#{ command } 2>&1` ) . to match_approval ( 'bash/error' )
1313 end
You can’t perform that action at this time.
0 commit comments