Define path with __dir__ (#6087)

Merge pull request 6087
This commit is contained in:
Bogdan 2017-07-26 02:20:20 +03:00 committed by jekyllbot
parent 8a017b5a2a
commit 8f1959bbc4
13 changed files with 19 additions and 19 deletions

View File

@ -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

View File

@ -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 }

View File

@ -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"

View File

@ -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"

View File

@ -1,4 +1,4 @@
$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.
#
@ -6,7 +6,7 @@ $LOAD_PATH.unshift File.dirname(__FILE__) # For use/testing when no gem is insta
#
# 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

View File

@ -113,7 +113,7 @@ RUBY
end
def site_template
File.expand_path("../../site_template", File.dirname(__FILE__))
File.expand_path("../../site_template", __dir__)
end
def scaffold_path

View File

@ -234,7 +234,7 @@ module Jekyll
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

View File

@ -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))

View File

@ -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}"

View File

@ -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 = {}

View File

@ -13,7 +13,7 @@ if ENV["CI"]
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"
@ -63,7 +63,7 @@ end
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)

View File

@ -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

View File

@ -9,7 +9,7 @@ class TestNewCommand < JekyllUnitTest
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