-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #57 from MauricioRobayo/feature/verification-script
Bash script to compare linters files
- Loading branch information
Showing
3 changed files
with
97 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# check-linters-confg | ||
|
||
`check-linters-config` is a Bash script to compare local files against the files on the master branch of this repository. It will check that files exist and that they are **identical** to the ones here. | ||
|
||
## Installation | ||
|
||
1. Copy the [`check-linters-conf.sh`](check-linters-conf.sh) file into someplace in the `$PATH` of your machine, for example `/usr/local/bin`: | ||
|
||
``` | ||
sudo wget -O /usr/local/bin/check-linters-config https://raw.githubusercontent.com/microverseinc/linters-config/master/scripts/check-linters-conf.sh | ||
``` | ||
|
||
2. Make it executable: | ||
|
||
``` | ||
sudo chmod +x /usr/local/bin/check-linters-config | ||
``` | ||
|
||
## Usage | ||
|
||
Run the command `check-linters-config` on the root of the repository you want to check. It takes as an argument the name of the directory you want to check against. | ||
|
||
``` | ||
$ check-linters-config ruby | ||
Files master/ruby/.stickler.yml and .stickler.yml differ | ||
Files master/ruby/.rubocop.yml and .rubocop.yml are identical | ||
``` | ||
|
||
The possible directories/options included are: | ||
|
||
- [css](https://github.com/microverseinc/linters-config/tree/master/css) | ||
- [javascript](https://github.com/microverseinc/linters-config/tree/master/javascript) | ||
- [react-redux](https://github.com/microverseinc/linters-config/tree/master/react-redux) | ||
- [ror](https://github.com/microverseinc/linters-config/tree/master/ror) | ||
- [ruby](https://github.com/microverseinc/linters-config/tree/master/ruby) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#/bin/bash | ||
|
||
base_url="https://raw.githubusercontent.com/microverseinc/linters-config" | ||
branch="master" | ||
usage=" | ||
Usage: check-linters-config dir | ||
Please provide a valid dir to compare againts. | ||
Valid options for dir: | ||
css | ||
javascript | ||
react-redux | ||
ror | ||
ruby | ||
Example: check-linters-config ruby | ||
" | ||
|
||
compare () { | ||
directory="$1" | ||
config_files="$2" | ||
for file in "${config_files[@]}"; do | ||
if [ -f "${file}" ]; then | ||
original_file="${branch}/${directory}/${file}" | ||
wget -qO- "${base_url}/${original_file}" | | ||
diff \ | ||
--brief \ | ||
--report-identical-files \ | ||
--ignore-all-space \ | ||
--ignore-blank-lines \ | ||
--strip-trailing-cr \ | ||
--label="${original_file}" \ | ||
- "${file}" | ||
else | ||
echo "File '${file}' is missing" | ||
fi | ||
done | ||
} | ||
|
||
case $1 in | ||
css) | ||
config_files=(".stickler.yml" "stylelint.config.js") | ||
;; | ||
ruby | ror) | ||
config_files=(".stickler.yml" ".rubocop.yml") | ||
;; | ||
javascript | react-redux) | ||
config_files=(".stickler.yml" ".eslintrc.json") | ||
;; | ||
*) | ||
echo "$usage" | ||
exit 1 | ||
esac | ||
|
||
compare "$1" "${config_files[@]}" |