pre-commit 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -14,7 +14,7 @@ class ConsoleLog
14
14
  end
15
15
 
16
16
  def run
17
- return true if staged_files.empty?
17
+ return true if staged_js_files.empty?
18
18
  if detected_bad_code?
19
19
  @error_message = "pre-commit: console.log found:\n"
20
20
  @error_message += instances_of_console_log_violations
@@ -25,11 +25,16 @@ class ConsoleLog
25
25
  end
26
26
 
27
27
  def detected_bad_code?
28
- system("grep -v \/\/ #{staged_files} | grep -qe \"console\\.log\"")
28
+ system("grep -v \/\/ #{staged_js_files} | grep -qe \"console\\.log\"")
29
29
  end
30
30
 
31
31
  def instances_of_console_log_violations
32
- `grep -nHe \"console\\.log\" #{staged_files}`
32
+ `grep -nHe \"console\\.log\" #{staged_js_files}`
33
33
  end
34
34
 
35
+ def staged_js_files
36
+ @staged_js_files ||= staged_files.split(" ").select do |file|
37
+ File.extname(file) == ".js"
38
+ end.join(" ")
39
+ end
35
40
  end
@@ -6,6 +6,11 @@ else
6
6
  cmd = "ruby -rrubygems "
7
7
  end
8
8
 
9
+ if !system("#{cmd} -rpre-commit -e '' 2> /dev/null")
10
+ $stderr.puts "pre-commit: WARNING: Skipping checks because the pre-commit gem is not installed. (Did you change your Ruby version?)"
11
+ exit(0)
12
+ end
13
+
9
14
  cmd << %Q{-e "require 'pre-commit'; PreCommit.run"}
10
15
 
11
16
  exit(system(cmd) ? 0 : 1)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pre-commit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-03 00:00:00.000000000 Z
12
+ date: 2012-08-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: execjs