Skip to content

Commit

Permalink
Define path with __dir__ (#186)
Browse files Browse the repository at this point in the history
Merge pull request 186
  • Loading branch information
DirtyF authored and jekyllbot committed Aug 25, 2017
1 parent bd31f86 commit 2a54328
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions lib/jekyll/jekyll-sitemap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def static_files

# Path to sitemap.xml template file
def source_path(file = "sitemap.xml")
File.expand_path "../#{file}", File.dirname(__FILE__)
File.expand_path "../#{file}", __dir__
end

# Destination for sitemap.xml file within the site source directory
Expand All @@ -43,7 +43,7 @@ def destination_path(file = "sitemap.xml")
end

def sitemap
site_map = PageWithoutAFile.new(@site, File.dirname(__FILE__), "", "sitemap.xml")
site_map = PageWithoutAFile.new(@site, __dir__, "", "sitemap.xml")
site_map.content = File.read(source_path).gsub(MINIFY_REGEX, "")
site_map.data["layout"] = nil
site_map.data["static_files"] = static_files.map(&:to_liquid)
Expand All @@ -52,7 +52,7 @@ def sitemap
end

def robots
robots = PageWithoutAFile.new(@site, File.dirname(__FILE__), "", "robots.txt")
robots = PageWithoutAFile.new(@site, __dir__, "", "robots.txt")
robots.content = File.read(source_path("robots.txt"))
robots.data["layout"] = nil
robots
Expand Down
2 changes: 1 addition & 1 deletion script/console
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#! /usr/bin/env ruby

def relative_to_root(path)
File.expand_path(path, File.dirname(File.dirname(__FILE__)))
File.expand_path(path, File.dirname(__dir__))
end

require 'jekyll'
Expand Down
10 changes: 5 additions & 5 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
require 'jekyll'
require File.expand_path('../lib/jekyll-sitemap', File.dirname(__FILE__))
require "jekyll"
require File.expand_path("../lib/jekyll-sitemap", __dir__)

Jekyll.logger.log_level = :error

RSpec.configure do |config|
config.run_all_when_everything_filtered = true
config.filter_run :focus
config.order = 'random'
config.order = "random"

SOURCE_DIR = File.expand_path("../fixtures", __FILE__)
DEST_DIR = File.expand_path("../dest", __FILE__)
SOURCE_DIR = File.expand_path("fixtures", __dir__)
DEST_DIR = File.expand_path("dest", __dir__)

def source_dir(*files)
File.join(SOURCE_DIR, *files)
Expand Down

0 comments on commit 2a54328

Please sign in to comment.