loading...
Cover image for Add Haml validation to CI/CD

Add Haml validation to CI/CD

abitrolly profile image Anatoli Babenia ・1 min read

TL;DR

Add this to your .gitlab-ci.yml or whatever CI/CD system you are using.

find . -name "*.haml" -type f -print0 | xargs -0L1 sh -c \
  'for arg do echo -n "$arg .. "; haml --check "$arg"; done' _

Explanation

Use find to find all .haml files in current directory recursively. Pass paths of find files to xargs. Use \0 symbol as file delimiter. For each file, run sh command. In sh command print path of the file and run haml --check on it.

find is necessary, because haml utility is unable to search for files on its own. xargs is needed, because find can not detect if executed program failed. sh is needed, because haml can not report the filename being checked.

Credits

Discussion

pic
Editor guide