1616# See the License for the specific language governing permissions and
1717# limitations under the License.
1818
19- # Script to update years for stdlib copyright notices to the current year .
19+ # Script to lint and automatically fix JavaScript files .
2020#
21- # Usage: update_copyright_years file1 [file2 file3 ...]
21+ # Usage: lint_javascript_files file1 [file2 file3 ...]
2222#
2323# Arguments:
2424#
@@ -37,7 +37,7 @@ root=$(git rev-parse --show-toplevel)
3737fix=" ${FIX:- 0} "
3838
3939# Files to lint:
40- files_to_lint=${ @ }
40+ files_to_lint=" $* "
4141
4242# Define the path to ESLint configuration file for linting examples:
4343eslint_examples_conf=" ${root} /etc/eslint/.eslintrc.examples.js"
@@ -50,12 +50,21 @@ eslint_benchmarks_conf="${root}/etc/eslint/.eslintrc.benchmarks.js"
5050
5151# Lint JavaScript source files:
5252files=$( echo " ${files_to_lint} " | tr ' ' ' \n' | grep ' \.js$' | grep -v -e ' /examples' -e ' /test' -e ' /benchmark' -e ' ^dist/' | tr ' \n' ' ' | sed ' s/ $//' )
53+
54+ # Build native addons if present:
55+ packages=$( echo " ${files} " | tr ' ' ' \n' | sed ' s/^lib\/node_modules\///g' | sed ' s/\/lib\/.*//g' | sort | uniq)
56+ for pkg in ${packages} ; do
57+ if [ -f " lib/node_modules/${pkg} /binding.gyp" ]; then
58+ NODE_ADDONS_PATTERN=" ${pkg} " make install-node-addons
59+ fi
60+ done
61+
5362if [[ -n " ${files} " ]]; then
5463 make lint-javascript-files FIX=" ${fix} " FILES=" ${files} "
5564fi
5665
5766# Lint JavaScript command-line interfaces...
58- file=$( echo ${files_to_lint} | tr ' ' ' \n' | grep ' \.js$' | grep -E ' /bin/cli$' | tr ' \n' ' ' | sed ' s/ $//' )
67+ file=$( echo " ${files_to_lint} " | tr ' ' ' \n' | grep ' \.js$' | grep -E ' /bin/cli$' | tr ' \n' ' ' | sed ' s/ $//' )
5968if [[ -n " ${file} " ]]; then
6069 make lint-javascript-files FIX=" ${fix} " FILES=" ${file} "
6170fi
0 commit comments