Serenity Operating System
1#!/usr/bin/env bash
2
3set -e
4
5script_path=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
6cd "${script_path}/.." || exit 1
7
8if [ "$#" -eq "0" ]; then
9 mapfile -t files < <(
10 git ls-files '*.py'
11 )
12else
13 files=()
14 for file in "$@"; do
15 if [[ "${file}" == *".py" ]]; then
16 files+=("${file}")
17 fi
18 done
19fi
20
21if (( ${#files[@]} )); then
22 if ! command -v flake8 >/dev/null 2>&1 ; then
23 echo "flake8 is not available, but python files need linting! Either skip this script, or install flake8."
24 exit 1
25 fi
26
27 flake8 "${files[@]}" --max-line-length=120
28else
29 echo "No py files to check."
30fi