Skip to content

Commit

Permalink
Makefile: handle cases when Bundler is not installed
Browse files Browse the repository at this point in the history
  • Loading branch information
maxim-belkin committed Aug 22, 2020
1 parent 07ef157 commit a2e4546
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,15 @@ MAKEFILES=Makefile $(wildcard *.mk)
PARSER=bin/markdown_ast.rb
DST=_site

ifneq (, $(wildcard Gemfile*))
JEKYLL := bundle exec jekyll
BUNDLE := $(shell which bundle 2>/dev/null)
GEMFILES := $(wildcard Gemfile Gemfile.lock)

ifneq (, $(GEMFILES))
ifneq (, $(BUNDLE))
JEKYLL := bundle exec jekyll
else
JEKYLL := jekyll
endif
else
JEKYLL := jekyll
endif
Expand Down Expand Up @@ -177,22 +184,26 @@ bundle : .vendor/bundle
@:

.vendor/bundle: Gemfile Gemfile.lock
ifneq (, $(wildcard Gemfile*))
ifeq (, $(BUNDLE))
@echo "Please install Bundler using 'gem install bundler'"
else ifeq (, $(GEMFILES))
@echo Can not create bundle: neither Gemfile nor Gemfile.lock have been found.
else
@bundle config set --local path '.vendor/bundle'
@bundle install
@bundle update --quiet github-pages
@touch .vendor/bundle
else
@echo Can not create bundle: neither Gemfile nor Gemfile.lock have been found.
endif

# Gemfile target below does nothing. This is intentional.
Gemfile:
@:

Gemfile.lock: Gemfile
ifneq (, $(wildcard Gemfile))
@bundle lock
else
ifeq (, $(BUNDLE))
@echo "Please install Bundler using 'gem install bundler'"
else ifeq (, $(wildcard Gemfile))
@echo Gemfile not found!
else
@bundle lock
endif

0 comments on commit a2e4546

Please sign in to comment.