mirror of
https://github.com/balena-io/etcher.git
synced 2025-07-23 11:16:39 +00:00
fix sanity-checks
This commit is contained in:
parent
d5a14031c6
commit
96c76177af
@ -38,6 +38,7 @@ DEV_FILES_REGEX=^\(tests\|scripts\)/
|
|||||||
# need to do a non-greedy match, which is why we're not using (.*)
|
# need to do a non-greedy match, which is why we're not using (.*)
|
||||||
REQUIRE_REGEX=require\\\(\'\([-_/\.a-z0-9]+\)\'\\\)
|
REQUIRE_REGEX=require\\\(\'\([-_/\.a-z0-9]+\)\'\\\)
|
||||||
JS_OR_JSON_REGEX=\.js\(on\)?$
|
JS_OR_JSON_REGEX=\.js\(on\)?$
|
||||||
|
HTML_REGEX=\.html$
|
||||||
|
|
||||||
# Check all js files stored in the repo can require() the packages they need
|
# Check all js files stored in the repo can require() the packages they need
|
||||||
git ls-tree -r HEAD | while IFS='' read line; do
|
git ls-tree -r HEAD | while IFS='' read line; do
|
||||||
@ -48,7 +49,7 @@ git ls-tree -r HEAD | while IFS='' read line; do
|
|||||||
extension=${filename##*.}
|
extension=${filename##*.}
|
||||||
if [[ "$extension" == "js" ]]; then
|
if [[ "$extension" == "js" ]]; then
|
||||||
# 'grep -v' to filter out any comment-blocks
|
# 'grep -v' to filter out any comment-blocks
|
||||||
grep 'require(' "$fullpath" | grep -v "^ \* " | while IFS='' read line; do
|
grep 'require(' "$fullpath" | grep -v -E "^ +\* " | while IFS='' read line; do
|
||||||
if [[ "$line" =~ $REQUIRE_REGEX ]]; then
|
if [[ "$line" =~ $REQUIRE_REGEX ]]; then
|
||||||
required=${BASH_REMATCH[1]}
|
required=${BASH_REMATCH[1]}
|
||||||
fi
|
fi
|
||||||
@ -62,6 +63,9 @@ git ls-tree -r HEAD | while IFS='' read line; do
|
|||||||
requirement_found=1
|
requirement_found=1
|
||||||
elif [[ -f "$localpath.js" ]] || [[ -f "$localpath/index.js" ]]; then
|
elif [[ -f "$localpath.js" ]] || [[ -f "$localpath/index.js" ]]; then
|
||||||
requirement_found=1
|
requirement_found=1
|
||||||
|
# Webpack HTML loader
|
||||||
|
elif [[ "$localpath" =~ $HTML_REGEX ]] && [[ -f "$localpath" ]]; then
|
||||||
|
requirement_found=1
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
required=${required%%/*}
|
required=${required%%/*}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user