niceCommit 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d49c5455a1428c239278f012fefb433b25b3021b
4
- data.tar.gz: 4752f6b92bfd68547b1cb21d54ba9f16b0c35863
3
+ metadata.gz: cddb494351e424ed60b83b2d6becffc8e39b0653
4
+ data.tar.gz: 7a430261f7da2e1a2fbc69e8d92a2f2d5d6662a6
5
5
  SHA512:
6
- metadata.gz: 7e3917bb5a549fa86fdfa80ccc796843cf2de7e48d68d03f673598e8d88b3b3f3feaa069cd715e9c0a38ffd28be5f1daa0e25159d73ec7fb0942002dac70b62e
7
- data.tar.gz: 0cd8290792cde71e129727619f42025b7118bebabbdd2c248f447bebff02fb8fb3cadf3193aab5496727a7e3a1d344392b3a1235e60769de07bbc0cd806b45b1
6
+ metadata.gz: b4d9918c339af23c33d8dad962923e6deb5a34472e8288c8ec630f229fdf51ca8600e7f51d9cce0a9db24a799b5fde1395a594920af9975bddec048ad929c8f5
7
+ data.tar.gz: 11312aa7b52499d7d0a822e979dfeceea79b889e38781157e285614a2d8d1aa7f26a1311e8c2dab9ec4bc8f9d873222be6403b2547295c69fff900ebee2ec552
@@ -0,0 +1,42 @@
1
+ #!/bin/bash
2
+
3
+ STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep ".jsx\{0,1\}$")
4
+
5
+ if [[ "$STAGED_FILES" = "" ]]; then
6
+ exit 0
7
+ fi
8
+
9
+ PASS=true
10
+
11
+ echo "Validating Javascript"
12
+
13
+ # Check for eslint
14
+ which eslint &> /dev/null
15
+ if [[ "$?" == 1 ]]; then
16
+ echo "Please install ESlint"
17
+ exit 1
18
+ fi
19
+
20
+ for FILE in $STAGED_FILES
21
+ do
22
+ eslint "$FILE"
23
+
24
+ if [[ "$?" == 0 ]]; then
25
+ echo "ESLint Passed: $FILE"
26
+ else
27
+ echo "****"
28
+ echo "ESLint Failed: $FILE"
29
+ PASS=false
30
+ fi
31
+ done
32
+
33
+ echo "Javascript validation completed!"
34
+
35
+ if ! $PASS; then
36
+ echo "COMMIT FAILED: Your commit contains files that should pass ESLint but do not. Please fix the ESLint errors and try again."
37
+ exit 1
38
+ else
39
+ echo "COMMIT SUCCEEDED"
40
+ fi
41
+
42
+ exit $?
@@ -0,0 +1,81 @@
1
+ #!/bin/bash
2
+
3
+ #Path to swiftlint
4
+ SWIFT_LINT=./Pods/SwiftLint/swiftlint
5
+
6
+
7
+
8
+ #if $SWIFT_LINT >/dev/null 2>&1; then
9
+ if [[ -e "${SWIFT_LINT}" ]]; then
10
+ count=0
11
+ for file_path in $(git ls-files -m --exclude-from=.gitignore | grep ".swift$"); do
12
+ export SCRIPT_INPUT_FILE_$count=$file_path
13
+ count=$((count + 1))
14
+ done
15
+
16
+ ##### Check for modified files in unstaged/Staged area #####
17
+ for file_path in $(git diff --name-only --cached | grep ".swift$"); do
18
+ export SCRIPT_INPUT_FILE_$count=$file_path
19
+ count=$((count + 1))
20
+ done
21
+
22
+ ##### Make the count avilable as global variable #####
23
+ export SCRIPT_INPUT_FILE_COUNT=$count
24
+
25
+ ## echo "${SCRIPT_INPUT_FILE_COUNT}"
26
+
27
+ ##### Lint files or exit if no files found for lintint #####
28
+ if [ "$count" -ne 0 ]; then
29
+
30
+ echo "*************************************************************"
31
+ echo "Found lintable files! Linting and fixing the fixible parts..."
32
+ echo "trying to AUTOCORRECT those files if needed.."
33
+ echo "*************************************************************"
34
+ echo ""
35
+
36
+ $SWIFT_LINT autocorrect --use-script-input-files --config .swiftlint.yml #autocorrects before commit.
37
+
38
+ ### lint again because autocorrect ignores some stuff...
39
+ ### strict will cause to fail on any warning.
40
+ echo ""
41
+ echo "*************************************************************"
42
+ echo "looking for linter errors or warnings..."
43
+ echo "*************************************************************"
44
+ echo ""
45
+ $SWIFT_LINT lint --strict --use-script-input-files --config .swiftlint.yml #autocorrects before commit.
46
+
47
+ else
48
+ echo "*************************************************************"
49
+ echo "No files to lint!"
50
+ echo "*************************************************************"
51
+ echo ""
52
+
53
+ fi
54
+
55
+ RESULT=$?
56
+
57
+ if [ $RESULT -eq 0 ]; then
58
+ echo "*************************************************************"
59
+ echo ""
60
+ echo "Violation found of the type WARNING! Must fix before commit!"
61
+ echo "*************************************************************"
62
+ echo ""
63
+
64
+ else
65
+ echo "*************************************************************"
66
+ echo ""
67
+ echo "Violation found of the type ERROR! Must fix before commit!"
68
+ echo "*************************************************************"
69
+ echo ""
70
+
71
+ fi
72
+
73
+ exit $RESULT
74
+
75
+ else
76
+
77
+ #### If SwiftLint is not installed, do not allow commit
78
+ echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint"
79
+ echo "If you have Homebrew, you can directly use `brew install swiftlint` to install SwiftLint"
80
+ exit 1
81
+ fi
File without changes
@@ -1,3 +1,3 @@
1
1
  module NiceCommit
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: niceCommit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Sanchez
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-09-22 00:00:00.000000000 Z
11
+ date: 2017-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -43,7 +43,7 @@ description: Execute pre-commit hooks to warranty code quality and style for And
43
43
  email:
44
44
  - michael@sanchezcr.com
45
45
  executables:
46
- - installHooks
46
+ - niceCommit
47
47
  extensions: []
48
48
  extra_rdoc_files: []
49
49
  files:
@@ -54,10 +54,11 @@ files:
54
54
  - README.md
55
55
  - Rakefile
56
56
  - availableHooks/checkStyle
57
+ - availableHooks/eslint
57
58
  - availableHooks/swiftLint
58
59
  - bin/console
59
60
  - bin/setup
60
- - exe/installHooks
61
+ - exe/niceCommit
61
62
  - lib/niceCommit.rb
62
63
  - lib/niceCommit/version.rb
63
64
  - niceCommit.gemspec