Skip to content

Commit

Permalink
#8 make shellCheckDirectory search recursively
Browse files Browse the repository at this point in the history
  • Loading branch information
jgizycki committed Mar 13, 2020
1 parent 49ed031 commit 7bb70de
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ lintDockerfile() // uses Dockerfile as default; optional parameter
```groovy
shellCheck() // search for all .sh files in folder and runs shellcheck
shellCheck(fileList) // fileList="a.sh b.sh" execute shellcheck on a custom list
shellCheckDirectory(DIRECTORY) // run shellcheck on all files in DIRECTORY; subdirectories are not checked
shellCheckDirectory(DIRECTORY) // run shellcheck on all files in DIRECTORY; files are searched recursively
```


Expand Down
6 changes: 3 additions & 3 deletions vars/shellCheck.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ def call(fileList) {
*
*/
def call() {
def fileList = sh (script: 'find . -path ./ecosystem -prune -o -type f -regex .*\\.sh -print', returnStdout: true)
fileList='"'+fileList.trim().replaceAll('\n','" "')+'"'
executeWithDocker(fileList)
def fileList = sh (script: 'find . -path ./ecosystem -prune -o -type f -regex .*\\.sh -print', returnStdout: true)
fileList='"'+fileList.trim().replaceAll('\n','" "')+'"'
executeWithDocker(fileList)
}

/*
Expand Down
11 changes: 7 additions & 4 deletions vars/shellCheckDirectory.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@
package com.cloudogu.ces.dogubuildlib

/**
* Run shellcheck on all files in directory
* subdirectories are not checked
* Run shellcheck on all files in directory.
* Files are matched recursively.
*
*/
def call(directoryName) {
def fileList = sh (script: "find ${direcotyName} -type f -regex .*\\.sh -print", returnStdout: true)
fileList='"'+fileList.trim().replaceAll('\n','" "')+'"'

docker.image('koalaman/shellcheck-alpine:stable').inside(){
sh "/bin/shellcheck ./${directoryName}/*.sh"
sh "/bin/shellcheck ${fileList}"
}
}
}

0 comments on commit 7bb70de

Please sign in to comment.