@@ -39,6 +39,13 @@ fix="${FIX:-0}"
3939# Files to lint:
4040files_to_lint=" $* "
4141
42+ # Filter out non-existent files:
43+ filter_existing_files () {
44+ echo " $1 " | tr ' ' ' \n' | while read -r f; do
45+ [ -f " $f " ] && printf ' %s ' " $f "
46+ done | sed ' s/ $//'
47+ }
48+
4249# Define the path to ESLint configuration file for linting examples:
4350eslint_examples_conf=" ${root} /etc/eslint/.eslintrc.examples.js"
4451
@@ -49,7 +56,7 @@ eslint_tests_conf="${root}/etc/eslint/.eslintrc.tests.js"
4956eslint_benchmarks_conf=" ${root} /etc/eslint/.eslintrc.benchmarks.js"
5057
5158# Lint JavaScript source files:
52- files=$( echo " ${files_to_lint} " | tr ' ' ' \n' | grep ' \.js$' | grep -v -e ' /examples' -e ' /test' -e ' /benchmark' -e ' ^dist/' | tr ' \n' ' ' | sed ' s/ $// ' )
59+ files=$( filter_existing_files " $( echo " ${files_to_lint} " | tr ' ' ' \n' | grep ' \.js$' | grep -v -e ' /examples' -e ' /test' -e ' /benchmark' -e ' ^dist/' | tr ' \n' ' ' ) " )
5360
5461# Build native addons if present:
5562packages=$( echo " ${files} " | tr ' ' ' \n' | sed ' s/^lib\/node_modules\///g' | sed ' s/\/lib\/.*//g' | sort | uniq)
@@ -64,25 +71,25 @@ if [[ -n "${files}" ]]; then
6471fi
6572
6673# Lint JavaScript command-line interfaces...
67- file=$( echo " ${files_to_lint} " | tr ' ' ' \n' | grep ' \.js$' | grep -E ' /bin/cli$' | tr ' \n' ' ' | sed ' s/ $// ' )
74+ file=$( filter_existing_files " $( echo " ${files_to_lint} " | tr ' ' ' \n' | grep ' \.js$' | grep -E ' /bin/cli$' | tr ' \n' ' ' ) " )
6875if [[ -n " ${file} " ]]; then
6976 make lint-javascript-files FIX=" ${fix} " FAST_FAIL=0 FILES=" ${file} "
7077fi
7178
7279# Lint JavaScript example files:
73- files=$( echo " ${files_to_lint} " | tr ' ' ' \n' | grep ' /examples/.*\.js$' | tr ' \n' ' ' | sed ' s/ $// ' )
80+ files=$( filter_existing_files " $( echo " ${files_to_lint} " | tr ' ' ' \n' | grep ' /examples/.*\.js$' | tr ' \n' ' ' ) " )
7481if [[ -n " ${files} " ]]; then
7582 make lint-javascript-files FIX=" ${fix} " FAST_FAIL=0 FILES=" ${files} " ESLINT_CONF=" ${eslint_examples_conf} "
7683fi
7784
7885# Lint JavaScript test files:
79- files=$( echo " ${files_to_lint} " | tr ' ' ' \n' | grep ' /test/.*\.js$' | tr ' \n' ' ' | sed ' s/ $// ' )
86+ files=$( filter_existing_files " $( echo " ${files_to_lint} " | tr ' ' ' \n' | grep ' /test/.*\.js$' | tr ' \n' ' ' ) " )
8087if [[ -n " ${files} " ]]; then
8188 make lint-javascript-files FIX=" ${fix} " FAST_FAIL=0 FILES=" ${files} " ESLINT_CONF=" ${eslint_tests_conf} "
8289fi
8390
8491# Lint JavaScript benchmark files:
85- files=$( echo " ${files_to_lint} " | tr ' ' ' \n' | grep ' /benchmark/.*\.js$' | tr ' \n' ' ' | sed ' s/ $// ' )
92+ files=$( filter_existing_files " $( echo " ${files_to_lint} " | tr ' ' ' \n' | grep ' /benchmark/.*\.js$' | tr ' \n' ' ' ) " )
8693if [[ -n " ${files} " ]]; then
8794 make lint-javascript-files FIX=" ${fix} " FAST_FAIL=0 FILES=" ${files} " ESLINT_CONF=" ${eslint_benchmarks_conf} "
8895fi
0 commit comments