Skip to content

Commit 8c3b543

Browse files
committed
Add BowerInstall post-{commit,checkout,merge,rewrite} hooks
1 parent ae80922 commit 8c3b543

File tree

10 files changed

+217
-0
lines changed

10 files changed

+217
-0
lines changed

config/default.yml

+36
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,15 @@ PostCheckout:
532532
required: false
533533
quiet: false
534534

535+
BowerInstall:
536+
enabled: false
537+
description: 'Installing bower dependencies'
538+
requires_files: true
539+
required_executable: 'bower'
540+
install_command: 'npm install -g bower'
541+
flags: ['install']
542+
include: 'bower.json'
543+
535544
IndexTags:
536545
enabled: false
537546
description: 'Generating tags file from source'
@@ -561,6 +570,15 @@ PostCommit:
561570
required: false
562571
quiet: false
563572

573+
BowerInstall:
574+
enabled: false
575+
description: 'Installing bower dependencies'
576+
requires_files: true
577+
required_executable: 'bower'
578+
install_command: 'npm install -g bower'
579+
flags: ['install']
580+
include: 'bower.json'
581+
564582
GitGuilt:
565583
enabled: false
566584
description: 'Calculating changes in blame since last commit'
@@ -597,6 +615,15 @@ PostMerge:
597615
requires_files: false
598616
quiet: false
599617

618+
BowerInstall:
619+
enabled: false
620+
description: 'Installing bower dependencies'
621+
requires_files: true
622+
required_executable: 'bower'
623+
install_command: 'npm install -g bower'
624+
flags: ['install']
625+
include: 'bower.json'
626+
600627
IndexTags:
601628
enabled: false
602629
description: 'Generating tags file from source'
@@ -625,6 +652,15 @@ PostRewrite:
625652
requires_files: false
626653
quiet: false
627654

655+
BowerInstall:
656+
enabled: false
657+
description: 'Installing bower dependencies'
658+
requires_files: true
659+
required_executable: 'bower'
660+
install_command: 'npm install -g bower'
661+
flags: ['install']
662+
include: 'bower.json'
663+
628664
IndexTags:
629665
enabled: false
630666
description: 'Generating tags file from source'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
require 'overcommit/hook/shared/bower_install'
2+
3+
module Overcommit::Hook::PostCheckout
4+
# Runs `bower install` when a change is detected in the repository's
5+
# dependencies.
6+
#
7+
# @see {Overcommit::Hook::Shared::BowerInstall}
8+
class BowerInstall < Base
9+
include Overcommit::Hook::Shared::BowerInstall
10+
end
11+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
require 'overcommit/hook/shared/bower_install'
2+
3+
module Overcommit::Hook::PostCommit
4+
# Runs `bower install` when a change is detected in the repository's
5+
# dependencies.
6+
#
7+
# @see {Overcommit::Hook::Shared::BowerInstall}
8+
class BowerInstall < Base
9+
include Overcommit::Hook::Shared::BowerInstall
10+
end
11+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
require 'overcommit/hook/shared/bower_install'
2+
3+
module Overcommit::Hook::PostMerge
4+
# Runs `bower install` when a change is detected in the repository's
5+
# dependencies.
6+
#
7+
# @see {Overcommit::Hook::Shared::BowerInstall}
8+
class BowerInstall < Base
9+
include Overcommit::Hook::Shared::BowerInstall
10+
end
11+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
require 'overcommit/hook/shared/bower_install'
2+
3+
module Overcommit::Hook::PostRewrite
4+
# Runs `bower install` when a change is detected in the repository's
5+
# dependencies.
6+
#
7+
# @see {Overcommit::Hook::Shared::BowerInstall}
8+
class BowerInstall < Base
9+
include Overcommit::Hook::Shared::BowerInstall
10+
end
11+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module Overcommit::Hook::Shared
2+
# Shared code used by all BowerInstall hooks. Runs `bower install` when a
3+
# change is detected in the repository's dependencies.
4+
#
5+
# @see http://bower.io/
6+
module BowerInstall
7+
def run
8+
result = execute(command)
9+
return :fail, result.stderr unless result.success?
10+
:pass
11+
end
12+
end
13+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
require 'spec_helper'
2+
3+
describe Overcommit::Hook::PostCheckout::BowerInstall do
4+
let(:config) { Overcommit::ConfigurationLoader.default_configuration }
5+
let(:context) { double('context') }
6+
subject { described_class.new(config, context) }
7+
8+
let(:result) { double('result') }
9+
10+
before do
11+
subject.stub(:execute).and_return(result)
12+
end
13+
14+
context 'when bower install exits successfully' do
15+
before do
16+
result.stub(:success?).and_return(true)
17+
end
18+
19+
it { should pass }
20+
end
21+
22+
context 'when bower install exits unsuccessfully' do
23+
before do
24+
result.stub(success?: false, stderr: normalize_indent(<<-OUT))
25+
bower EMALFORMED Failed to read bower.json
26+
OUT
27+
end
28+
29+
it { should fail_hook }
30+
end
31+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
require 'spec_helper'
2+
3+
describe Overcommit::Hook::PostCommit::BowerInstall do
4+
let(:config) { Overcommit::ConfigurationLoader.default_configuration }
5+
let(:context) { double('context') }
6+
subject { described_class.new(config, context) }
7+
8+
let(:result) { double('result') }
9+
10+
before do
11+
subject.stub(:execute).and_return(result)
12+
end
13+
14+
context 'when bower install exits successfully' do
15+
before do
16+
result.stub(:success?).and_return(true)
17+
end
18+
19+
it { should pass }
20+
end
21+
22+
context 'when bower install exits unsuccessfully' do
23+
before do
24+
result.stub(success?: false, stderr: normalize_indent(<<-OUT))
25+
bower EMALFORMED Failed to read bower.json
26+
OUT
27+
end
28+
29+
it { should fail_hook }
30+
end
31+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
require 'spec_helper'
2+
3+
describe Overcommit::Hook::PostMerge::BowerInstall do
4+
let(:config) { Overcommit::ConfigurationLoader.default_configuration }
5+
let(:context) { double('context') }
6+
subject { described_class.new(config, context) }
7+
8+
let(:result) { double('result') }
9+
10+
before do
11+
subject.stub(:execute).and_return(result)
12+
end
13+
14+
context 'when bower install exits successfully' do
15+
before do
16+
result.stub(:success?).and_return(true)
17+
end
18+
19+
it { should pass }
20+
end
21+
22+
context 'when bower install exits unsuccessfully' do
23+
before do
24+
result.stub(success?: false, stderr: normalize_indent(<<-OUT))
25+
bower EMALFORMED Failed to read bower.json
26+
OUT
27+
end
28+
29+
it { should fail_hook }
30+
end
31+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
require 'spec_helper'
2+
3+
describe Overcommit::Hook::PostRewrite::BowerInstall do
4+
let(:config) { Overcommit::ConfigurationLoader.default_configuration }
5+
let(:context) { double('context') }
6+
subject { described_class.new(config, context) }
7+
8+
let(:result) { double('result') }
9+
10+
before do
11+
subject.stub(:execute).and_return(result)
12+
end
13+
14+
context 'when bower install exits successfully' do
15+
before do
16+
result.stub(:success?).and_return(true)
17+
end
18+
19+
it { should pass }
20+
end
21+
22+
context 'when bower install exits unsuccessfully' do
23+
before do
24+
result.stub(success?: false, stderr: normalize_indent(<<-OUT))
25+
bower EMALFORMED Failed to read bower.json
26+
OUT
27+
end
28+
29+
it { should fail_hook }
30+
end
31+
end

0 commit comments

Comments
 (0)