overcommit 0.1.4 → 0.1.5

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: 1c7ae9be51eb3b0d57670dc28a29c359ec89c040
4
- data.tar.gz: 6830fbb57c870026962e5ea7b98b74a2ae69ca78
3
+ metadata.gz: ee54344839806219b40d78711ba92a3d75807f78
4
+ data.tar.gz: 943596ad2a69862b7495b714cb5a7047c86a6faa
5
5
  SHA512:
6
- metadata.gz: faa4abb76a1d4b681b29bcdf0bfa84d9d55498fd8e472bc654ffd4ce7dd3edbcd49da126f1299ca49efc519f7310b023afb7229c2d03a9ca0b2535eb92ee0f15
7
- data.tar.gz: 817e12dcedd4b6a624fb9eb5203443fd81279d130f37a65613e30126e71d8337a51f65d6e85a3f930a4d5aa7c13d13c940053851da47793d4bfa536f84021558
6
+ metadata.gz: 38c3e9ab81ed52c14bca93297c3ad2fa9aefb6350460ccb6f46976a5559cc7c08638c3c3124d396e91a9349a376cadc9a7a812ca3b235baa9bb49898f1eabd84
7
+ data.tar.gz: afeda1f2ba01a717d5b5d120ce8d1a5e3bba0fc77f68062d3a7994e81e35ecfe19061d106aeb445dd7488617292b00eafd647d478b6877096e40662cf8752000
@@ -28,19 +28,13 @@ for (i = 0; i < arguments.length; i++) {
28
28
  source = readFile(file);
29
29
  result = JSHINT(source, options);
30
30
 
31
- if (result === true) {
32
- print(arguments[i] + " -- OK");
33
- }
34
- else {
31
+ if (!result) {
35
32
  for (j = 0; j < JSHINT.errors.length; j++) {
36
33
  error = JSHINT.errors[j];
37
34
 
38
- print("ERROR in " + file + " at " + error.line + ":" + error.character);
39
- print("");
40
- print("\t" + error.reason);
41
- print("");
35
+ print(file + ": line " + error.line + ", col " + error.character + ", " +
36
+ error.reason);
42
37
  print("\t" + error.evidence);
43
- print("");
44
38
  }
45
39
  }
46
40
  }
@@ -3,16 +3,26 @@ module Overcommit::GitHook
3
3
  include HookRegistry
4
4
  file_type :js
5
5
 
6
- JS_HINT_PATH = Overcommit::Utils.script_path 'jshint.js'
7
- JS_HINT_RUNNER_PATH = Overcommit::Utils.script_path 'jshint_runner.js'
8
-
9
6
  def run_check
10
- return :warn, "Rhino is not installed" unless in_path? 'rhino'
7
+ return :warn, 'Need either `jshint` or `rhino` in path' unless runner
8
+
9
+ output = runner.call(staged.join(' ')).split("\n")
10
+ return (output.none? ? :good : :bad), output
11
+ end
12
+
13
+ private
11
14
 
12
- paths = staged.join(' ')
15
+ JS_HINT_PATH = Overcommit::Utils.script_path 'jshint.js'
16
+ JS_HINT_RUNNER_PATH = Overcommit::Utils.script_path 'jshint_runner.js'
13
17
 
14
- output = `rhino -strict -f #{JS_HINT_PATH} #{JS_HINT_RUNNER_PATH} #{paths} 2>&1 | grep -v warning | grep -v -e '^js: '`
15
- return (output !~ /^ERROR/ ? :good : :bad), output
18
+ def runner
19
+ if in_path? 'jshint'
20
+ lambda { |paths| `jshint #{paths}` }
21
+ elsif in_path? 'rhino'
22
+ lambda do |paths|
23
+ `rhino -strict -f #{JS_HINT_PATH} #{JS_HINT_RUNNER_PATH} #{paths} 2>&1 | grep -v warning | grep -v -e '^js: '`
24
+ end
25
+ end
16
26
  end
17
27
  end
18
28
  end
@@ -1,3 +1,3 @@
1
1
  module Overcommit
2
- VERSION = '0.1.4'
2
+ VERSION = '0.1.5'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: overcommit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Causes Engineering
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-29 00:00:00.000000000 Z
11
+ date: 2013-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec