Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix RSpec #175

Merged
merged 2 commits into from
May 4, 2021
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
10 changes: 5 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ go:
notifications:
email: false

# before_script:
# - sudo apt-get -q install ruby
# - gem install bundler
# - bundle install
before_script:
- sudo apt-get -q install ruby
- gem install bundler
- bundle install

script:
# - bundle exec rspec
- bundle exec rspec
- go test ./cmd
35 changes: 29 additions & 6 deletions spec/fixtures/pre-commit
Original file line number Diff line number Diff line change
@@ -1,10 +1,33 @@
#!/bin/bash
#!/bin/sh

# If can't find lefthook in global scope
# we suppose it in local npm package
if ! type lefthook >/dev/null
if [ "$LEFTHOOK" = "0" ]; then
exit 0
fi

if [ -t 1 ] ; then
exec < /dev/tty ; # <- enables interactive shell
fi

dir="$(cd "$(dirname "$(dirname "$(dirname "$0")")")" >/dev/null 2>&1 || exit ; pwd -P)"


cmd="lefthook run pre-commit $@"

if lefthook -h >/dev/null 2>&1
then
eval $cmd
elif test -f "$dir/node_modules/@arkweid/lefthook/bin/lefthook"
then
eval $dir/node_modules/@arkweid/lefthook/bin/$cmd
elif bundle exec lefthook -h >/dev/null 2>&1
then
bundle exec $cmd
elif npx lefthook -h >/dev/null 2>&1
then
npx $cmd
elif yarn lefthook -h >/dev/null 2>&1
then
exec npx lefthook run pre-commit $@
yarn $cmd
else
exec lefthook run pre-commit $@
echo "Can't find lefthook in PATH"
fi
35 changes: 29 additions & 6 deletions spec/fixtures/pre-push
Original file line number Diff line number Diff line change
@@ -1,10 +1,33 @@
#!/bin/bash
#!/bin/sh

# If can't find lefthook in global scope
# we suppose it in local npm package
if ! type lefthook >/dev/null
if [ "$LEFTHOOK" = "0" ]; then
exit 0
fi

if [ -t 1 ] ; then
exec < /dev/tty ; # <- enables interactive shell
fi

dir="$(cd "$(dirname "$(dirname "$(dirname "$0")")")" >/dev/null 2>&1 || exit ; pwd -P)"


cmd="lefthook run pre-push $@"

if lefthook -h >/dev/null 2>&1
then
eval $cmd
elif test -f "$dir/node_modules/@arkweid/lefthook/bin/lefthook"
then
eval $dir/node_modules/@arkweid/lefthook/bin/$cmd
elif bundle exec lefthook -h >/dev/null 2>&1
then
bundle exec $cmd
elif npx lefthook -h >/dev/null 2>&1
then
npx $cmd
elif yarn lefthook -h >/dev/null 2>&1
then
exec npx lefthook run pre-push $@
yarn $cmd
else
exec lefthook run pre-push $@
echo "Can't find lefthook in PATH"
fi
3 changes: 2 additions & 1 deletion spec/support/file_structure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ class << self
attr_accessor :root

def have_git
FileUtils.mkdir_p(File.join(tmp, '.git', 'hooks'))
FileUtils.mkdir_p(File.join(tmp))
_, _, _ = Open3.capture3('git init', chdir: tmp)
end

def make_scripts_preset
Expand Down