Allow passing arguments to functions
This commit is contained in:
		
							parent
							
								
									bb695de69f
								
							
						
					
					
						commit
						c7f7b0c6fb
					
				
							
								
								
									
										2
									
								
								examples
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								examples
									
									
									
									
									
								
							| @ -7,7 +7,7 @@ | ||||
| 
 | ||||
| ⚡️build() { | ||||
|   _help-line "Build an incredible script" "$@" | ||||
|   echo "echo hi" > .generated/potato | ||||
|   echo 'echo hi; echo "$@"' > .generated/potato | ||||
|   chmod +x .generated/potato | ||||
| } | ||||
| 
 | ||||
|  | ||||
| @ -42,7 +42,7 @@ Look! It's like a task runner! | ||||
| cd $(dirname $0) | ||||
| 
 | ||||
| ⚡build() { | ||||
|   echo "echo hi" > .generated/potato | ||||
|   echo 'echo hi; echo "$@"' > .generated/potato | ||||
|   chmod +x .generated/potato | ||||
| } | ||||
| 
 | ||||
|  | ||||
| @ -30,6 +30,20 @@ testReferingToALightningFunctionWorks() { | ||||
|   assertContains "$STDOUT" "Good Bye." | ||||
| } | ||||
| 
 | ||||
| testArgumentsArePassedToLightningFunctions() { | ||||
|   echo ' | ||||
|   #!/usr/bin/env bash | ||||
| 
 | ||||
|   ⚡hello() { echo "Hello, $@!" ; } | ||||
|   ' > go | ||||
| 
 | ||||
|   echo "source $REPO_ROOT/⚡" >> go | ||||
|   chmod +x go | ||||
| 
 | ||||
|   try ./go hello banana | ||||
|   assertContains "$STDOUT" "Hello, banana!" | ||||
| } | ||||
| 
 | ||||
| testDefiningALightningFunctionWorksWithSelector16() { | ||||
|   echo ' | ||||
|   #!/usr/bin/env bash | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user