Class: PreCommit::Checks::Local
- Inherits:
-
Plugin
- Object
- Plugin
- PreCommit::Checks::Local
show all
- Defined in:
- lib/plugins/pre_commit/checks/local.rb
Instance Attribute Summary collapse
Attributes inherited from Plugin
#config, #pluginator
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Plugin
#initialize, #name
Instance Attribute Details
#script ⇒ Object
19
20
21
22
23
|
# File 'lib/plugins/pre_commit/checks/local.rb', line 19
def script
@script ||= ["config/pre_commit.rb", "config/pre-commit.rb"].detect do |file|
File.exist?(file)
end
end
|
Class Method Details
.description ⇒ Object
15
16
17
|
# File 'lib/plugins/pre_commit/checks/local.rb', line 15
def self.description
"Executes a custom script located at config/pre_commit.rb"
end
|
Instance Method Details
#call(staged_files) ⇒ Object
9
10
11
12
13
|
# File 'lib/plugins/pre_commit/checks/local.rb', line 9
def call(staged_files)
return unless script
output = `ruby #{script} #{staged_files.join(" ")} 2>&1`
"#{script} failed:\n#{output}" unless $?.success?
end
|