Skip to content

Commit

Permalink
Define path with __dir__ (jekyll#6087)
Browse files Browse the repository at this point in the history
Merge pull request 6087
  • Loading branch information
bogdanvlviv authored and jekyllbot committed Jul 25, 2017
1 parent 8a017b5 commit 8f1959b
Show file tree
Hide file tree
Showing 13 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ group :test do
gem "rspec"
gem "rspec-mocks"
gem "rubocop", "~> 0.49.1"
gem "test-dependency-theme", :path => File.expand_path("./test/fixtures/test-dependency-theme", File.dirname(__FILE__))
gem "test-theme", :path => File.expand_path("./test/fixtures/test-theme", File.dirname(__FILE__))
gem "test-dependency-theme", :path => File.expand_path("test/fixtures/test-dependency-theme", __dir__)
gem "test-theme", :path => File.expand_path("test/fixtures/test-theme", __dir__)

gem "jruby-openssl" if RUBY_ENGINE == "jruby"
end
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ require "rdoc"
require "date"
require "yaml"

$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "lib"))
$LOAD_PATH.unshift File.expand_path("lib", __dir__)
require "jekyll/version"

Dir.glob("rake/**.rake").each { |f| import f }
Expand Down
2 changes: 1 addition & 1 deletion exe/jekyll
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env ruby
STDOUT.sync = true

$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
$LOAD_PATH.unshift File.expand_path("../lib", __dir__)

require "jekyll"
require "mercenary"
Expand Down
2 changes: 1 addition & 1 deletion jekyll.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# coding: utf-8

lib = File.expand_path("../lib", __FILE__)
lib = File.expand_path("lib", __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "jekyll/version"

Expand Down
4 changes: 2 additions & 2 deletions lib/jekyll.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
$LOAD_PATH.unshift File.dirname(__FILE__) # For use/testing when no gem is installed
$LOAD_PATH.unshift __dir__ # For use/testing when no gem is installed

# Require all of the Ruby files in the given directory.
#
# path - The String relative path from here to the directory.
#
# Returns nothing.
def require_all(path)
glob = File.join(File.dirname(__FILE__), path, "*.rb")
glob = File.join(__dir__, path, "*.rb")
Dir[glob].sort.each do |f|
require f
end
Expand Down
2 changes: 1 addition & 1 deletion lib/jekyll/commands/new.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def create_sample_files(path)
end

def site_template
File.expand_path("../../site_template", File.dirname(__FILE__))
File.expand_path("../../site_template", __dir__)
end

def scaffold_path
Expand Down
2 changes: 1 addition & 1 deletion lib/jekyll/commands/serve.rb
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def start_callback(detached)

private
def mime_types
file = File.expand_path("../mime.types", File.dirname(__FILE__))
file = File.expand_path("../mime.types", __dir__)
WEBrick::HTTPUtils.load_mime_types(file)
end
end
Expand Down
4 changes: 2 additions & 2 deletions script/console
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/usr/bin/env ruby

require 'pry'
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), *%w{ .. lib })
$LOAD_PATH.unshift File.expand_path("../lib", __dir__)
require 'jekyll'

TEST_DIR = File.expand_path(File.join(File.dirname(__FILE__), *%w{ .. test }))
TEST_DIR = File.expand_path("../test", __dir__)

def fixture_site(overrides = {})
Jekyll::Site.new(site_configuration(overrides))
Expand Down
4 changes: 2 additions & 2 deletions script/stackprof
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
require "bundler/setup"
require "json"
require "stackprof"
require File.expand_path("../../lib/jekyll", __FILE__)
require File.expand_path("../lib/jekyll", __dir__)

MODE = ARGV.first || "cpu"
PROF_OUTPUT_FILE = File.expand_path("../../tmp/stackprof-#{MODE}-#{Time.now.strftime("%Y%m%d%H%M")}.dump", __FILE__)
PROF_OUTPUT_FILE = File.expand_path("../tmp/stackprof-#{MODE}-#{Time.now.strftime("%Y%m%d%H%M")}.dump", __dir__)

puts "Stackprof Mode: #{MODE}"

Expand Down
2 changes: 1 addition & 1 deletion script/vendor-mimes
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
require 'json'
require 'open-uri'

config = File.expand_path "../lib/jekyll/mime.types", File.dirname(__FILE__)
config = File.expand_path "../lib/jekyll/mime.types", __dir__

# Create an array of vendored mimetype => [extensions]
mimes = {}
Expand Down
4 changes: 2 additions & 2 deletions test/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def jruby?
require "simplecov"
SimpleCov.start
else
require File.expand_path("../simplecov_custom_profile", __FILE__)
require File.expand_path("simplecov_custom_profile", __dir__)
SimpleCov.start "gem" do
add_filter "/vendor/gem"
add_filter "/vendor/bundle"
Expand Down Expand Up @@ -63,7 +63,7 @@ def refute_exist(filename, msg = nil)

module DirectoryHelpers
def root_dir(*subdirs)
File.join(File.dirname(File.dirname(__FILE__)), *subdirs)
File.expand_path(File.join("..", *subdirs), __dir__)
end

def dest_dir(*subdirs)
Expand Down
4 changes: 2 additions & 2 deletions test/test_convertible.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ class TestConvertible < JekyllUnitTest
setup do
@convertible = OpenStruct.new(
"site" => Site.new(Jekyll.configuration(
"source" => File.expand_path("../fixtures", __FILE__)
"source" => File.expand_path("fixtures", __dir__)
))
)
@convertible.extend Jekyll::Convertible
@base = File.expand_path("../fixtures", __FILE__)
@base = File.expand_path("fixtures", __dir__)
end

should "parse the front matter correctly" do
Expand Down
2 changes: 1 addition & 1 deletion test/test_new_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def dir_contents(path)
end

def site_template
File.expand_path("../lib/site_template", File.dirname(__FILE__))
File.expand_path("../lib/site_template", __dir__)
end

context "when args contains a path" do
Expand Down

0 comments on commit 8f1959b

Please sign in to comment.