Skip to content
Merged
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
36 changes: 36 additions & 0 deletions config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,15 @@ PostCheckout:
required: false
quiet: false

BowerInstall:
enabled: false
description: 'Installing bower dependencies'
requires_files: true
required_executable: 'bower'
install_command: 'npm install -g bower'
flags: ['install']
include: 'bower.json'

IndexTags:
enabled: false
description: 'Generating tags file from source'
Expand Down Expand Up @@ -561,6 +570,15 @@ PostCommit:
required: false
quiet: false

BowerInstall:
enabled: false
description: 'Installing bower dependencies'
requires_files: true
required_executable: 'bower'
install_command: 'npm install -g bower'
flags: ['install']
include: 'bower.json'

GitGuilt:
enabled: false
description: 'Calculating changes in blame since last commit'
Expand Down Expand Up @@ -597,6 +615,15 @@ PostMerge:
requires_files: false
quiet: false

BowerInstall:
enabled: false
description: 'Installing bower dependencies'
requires_files: true
required_executable: 'bower'
install_command: 'npm install -g bower'
flags: ['install']
include: 'bower.json'

IndexTags:
enabled: false
description: 'Generating tags file from source'
Expand Down Expand Up @@ -625,6 +652,15 @@ PostRewrite:
requires_files: false
quiet: false

BowerInstall:
enabled: false
description: 'Installing bower dependencies'
requires_files: true
required_executable: 'bower'
install_command: 'npm install -g bower'
flags: ['install']
include: 'bower.json'

IndexTags:
enabled: false
description: 'Generating tags file from source'
Expand Down
11 changes: 11 additions & 0 deletions lib/overcommit/hook/post_checkout/bower_install.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require 'overcommit/hook/shared/bower_install'

module Overcommit::Hook::PostCheckout
# Runs `bower install` when a change is detected in the repository's
# dependencies.
#
# @see {Overcommit::Hook::Shared::BowerInstall}
class BowerInstall < Base
include Overcommit::Hook::Shared::BowerInstall
end
end
11 changes: 11 additions & 0 deletions lib/overcommit/hook/post_commit/bower_install.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require 'overcommit/hook/shared/bower_install'

module Overcommit::Hook::PostCommit
# Runs `bower install` when a change is detected in the repository's
# dependencies.
#
# @see {Overcommit::Hook::Shared::BowerInstall}
class BowerInstall < Base
include Overcommit::Hook::Shared::BowerInstall
end
end
11 changes: 11 additions & 0 deletions lib/overcommit/hook/post_merge/bower_install.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require 'overcommit/hook/shared/bower_install'

module Overcommit::Hook::PostMerge
# Runs `bower install` when a change is detected in the repository's
# dependencies.
#
# @see {Overcommit::Hook::Shared::BowerInstall}
class BowerInstall < Base
include Overcommit::Hook::Shared::BowerInstall
end
end
11 changes: 11 additions & 0 deletions lib/overcommit/hook/post_rewrite/bower_install.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require 'overcommit/hook/shared/bower_install'

module Overcommit::Hook::PostRewrite
# Runs `bower install` when a change is detected in the repository's
# dependencies.
#
# @see {Overcommit::Hook::Shared::BowerInstall}
class BowerInstall < Base
include Overcommit::Hook::Shared::BowerInstall
end
end
13 changes: 13 additions & 0 deletions lib/overcommit/hook/shared/bower_install.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
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
end
end
end
31 changes: 31 additions & 0 deletions spec/overcommit/hook/post_checkout/bower_install_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
require 'spec_helper'

describe Overcommit::Hook::PostCheckout::BowerInstall do
let(:config) { Overcommit::ConfigurationLoader.default_configuration }
let(:context) { double('context') }
subject { described_class.new(config, context) }

let(:result) { double('result') }

before do
subject.stub(:execute).and_return(result)
end

context 'when bower install exits successfully' do
before do
result.stub(:success?).and_return(true)
end

it { should pass }
end

context 'when bower install exits unsuccessfully' do
before do
result.stub(success?: false, stderr: normalize_indent(<<-OUT))
bower EMALFORMED Failed to read bower.json
OUT
end

it { should fail_hook }
end
end
31 changes: 31 additions & 0 deletions spec/overcommit/hook/post_commit/bower_install_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
require 'spec_helper'

describe Overcommit::Hook::PostCommit::BowerInstall do
let(:config) { Overcommit::ConfigurationLoader.default_configuration }
let(:context) { double('context') }
subject { described_class.new(config, context) }

let(:result) { double('result') }

before do
subject.stub(:execute).and_return(result)
end

context 'when bower install exits successfully' do
before do
result.stub(:success?).and_return(true)
end

it { should pass }
end

context 'when bower install exits unsuccessfully' do
before do
result.stub(success?: false, stderr: normalize_indent(<<-OUT))
bower EMALFORMED Failed to read bower.json
OUT
end

it { should fail_hook }
end
end
31 changes: 31 additions & 0 deletions spec/overcommit/hook/post_merge/bower_install_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
require 'spec_helper'

describe Overcommit::Hook::PostMerge::BowerInstall do
let(:config) { Overcommit::ConfigurationLoader.default_configuration }
let(:context) { double('context') }
subject { described_class.new(config, context) }

let(:result) { double('result') }

before do
subject.stub(:execute).and_return(result)
end

context 'when bower install exits successfully' do
before do
result.stub(:success?).and_return(true)
end

it { should pass }
end

context 'when bower install exits unsuccessfully' do
before do
result.stub(success?: false, stderr: normalize_indent(<<-OUT))
bower EMALFORMED Failed to read bower.json
OUT
end

it { should fail_hook }
end
end
31 changes: 31 additions & 0 deletions spec/overcommit/hook/post_rewrite/bower_install_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
require 'spec_helper'

describe Overcommit::Hook::PostRewrite::BowerInstall do
let(:config) { Overcommit::ConfigurationLoader.default_configuration }
let(:context) { double('context') }
subject { described_class.new(config, context) }

let(:result) { double('result') }

before do
subject.stub(:execute).and_return(result)
end

context 'when bower install exits successfully' do
before do
result.stub(:success?).and_return(true)
end

it { should pass }
end

context 'when bower install exits unsuccessfully' do
before do
result.stub(success?: false, stderr: normalize_indent(<<-OUT))
bower EMALFORMED Failed to read bower.json
OUT
end

it { should fail_hook }
end
end