Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions lib/overcommit/hook/shared/bower_install.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
require 'overcommit/hook/shared/simple_install'

module Overcommit::Hook::Shared
# Shared code used by all BowerInstall hooks. Runs `bower install` when a
# change is detected in the repository's dependencies.
#
# @see http://bower.io/
module BowerInstall
def run
result = execute(command)
return :fail, result.stderr unless result.success?
:pass
include SimpleInstall

def fail_output
@result.stderr
end
end
end
10 changes: 6 additions & 4 deletions lib/overcommit/hook/shared/bundle_install.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
require 'overcommit/hook/shared/simple_install'

module Overcommit::Hook::Shared
# Shared code used by all BundleInstall hooks. Runs `bundle install` when a
# change is detected in the repository's dependencies.
#
# @see http://bundler.io/
module BundleInstall
def run
result = execute(command)
return :fail, result.stdout unless result.success?
:pass
include SimpleInstall

def fail_output
@result.stdout
end
end
end
10 changes: 6 additions & 4 deletions lib/overcommit/hook/shared/composer_install.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
require 'overcommit/hook/shared/simple_install'

module Overcommit::Hook::Shared
# Shared code used by all ComposerInstall hooks. Runs `composer install` when
# a change is detected in the repository's dependencies.
#
# @see https://getcomposer.org/
module ComposerInstall
def run
result = execute(command)
return :fail, result.stdout unless result.success?
:pass
include SimpleInstall

def fail_output
@result.stdout
end
end
end
10 changes: 6 additions & 4 deletions lib/overcommit/hook/shared/npm_install.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
require 'overcommit/hook/shared/simple_install'

module Overcommit::Hook::Shared
# Shared code used by all NpmInstall hooks. Runs `npm install` when a change
# is detected in the repository's dependencies.
#
# @see https://www.npmjs.com/
module NpmInstall
def run
result = execute(command)
return :fail, result.stderr unless result.success?
:pass
include SimpleInstall

def fail_output
@result.stderr
end
end
end
14 changes: 14 additions & 0 deletions lib/overcommit/hook/shared/simple_install.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module Overcommit::Hook::Shared
# Simple template for X-Install hooks.
module SimpleInstall
def run
@result = execute(command)
return :fail, fail_output unless @result.success?
:pass
end

def fail_output
raise NotImplementedError
end
end
end
10 changes: 6 additions & 4 deletions lib/overcommit/hook/shared/yarn_install.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
require 'overcommit/hook/shared/simple_install'

module Overcommit::Hook::Shared
# Shared code used by all YarnInstall hooks. Runs `yarn install` when a change
# is detected in the repository's dependencies.
#
# @see https://yarnpkg.com/
module YarnInstall
def run
result = execute(command)
return :fail, result.stderr unless result.success?
:pass
include SimpleInstall

def fail_output
@result.stderr
end
end
end