Skip to content

Commit dad0985

Browse files
committed
Create function to source a resource
1 parent 69dca77 commit dad0985

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,10 @@ Checks if the file $SODA_USER_HOME/$type/$NAMESPACE/$path exists using the names
230230
source $FILE
231231
}
232232

233+
### load ([type] path)
234+
235+
Call `#exists` and, if the file exists, `source` it.
236+
233237
### resource ([type] path)
234238

235239
Returns the file $SODA_USER_HOME/$type/$NAMESPACE/$path using the namespace of the invoked task or imported namespace without checking if the file exists. If the *type* is not passed then **resources** will be used. For use with the **config** type, use the `config` builtin function. The `config` function redirects to the resource function using *config* as the first parameter and the given parameter as the second parameter.

scripts/core.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,11 @@ config() {
327327
resource config $1
328328
}
329329

330+
# Loads the given file (if exists). The file is checked using #exists function
331+
load() {
332+
exists "$@" && source "$FILE"
333+
}
334+
330335
# Checks if a resource exists based on the current namespace.
331336
exists() {
332337
FILE="$(resource "$@")"

0 commit comments

Comments
 (0)