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

Make store paths absolute #1357

Merged
merged 1 commit into from Sep 15, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 5 additions & 3 deletions nanoc/lib/nanoc/base/repos/store.rb
Expand Up @@ -40,10 +40,12 @@ def initialize(filename, version)

# Logic for building tmp path from active environment and store name
# @api private
contract C::KeywordArgs[config: Nanoc::Int::Configuration, store_name: String] => String
contract C::KeywordArgs[config: Nanoc::Int::Configuration, store_name: String] => C::AbsolutePathString
def self.tmp_path_for(store_name:, config:)
# FIXME: make absolute
File.join(tmp_path_prefix(config.output_dir), store_name)
File.absolute_path(
File.join(tmp_path_prefix(config.output_dir), store_name),
config.dir,
)
end

def self.tmp_path_prefix(output_dir)
Expand Down
16 changes: 8 additions & 8 deletions nanoc/spec/nanoc/base/repos/store_spec.rb
Expand Up @@ -23,22 +23,22 @@ def gen_hash(path)

context 'output dir is unspecified' do
let(:config_hash) { {} }
it { is_expected.to eql("tmp/nanoc/#{hash_output}/giraffes") }
it { is_expected.to eql(Dir.getwd + "/tmp/nanoc/#{hash_output}/giraffes") }
end

context 'output dir at root is specified' do
let(:config_hash) { { output_dir: 'output-default' } }
it { is_expected.to eql("tmp/nanoc/#{hash_output_default}/giraffes") }
it { is_expected.to eql(Dir.getwd + "/tmp/nanoc/#{hash_output_default}/giraffes") }
end

context 'output dir in default env is specified' do
let(:config_hash) { { environments: { default: { output_dir: 'output-default' } } } }
it { is_expected.to eql("tmp/nanoc/#{hash_output_default}/giraffes") }
it { is_expected.to eql(Dir.getwd + "/tmp/nanoc/#{hash_output_default}/giraffes") }
end

context 'output dir in other env is specified' do
let(:config_hash) { { environments: { production: { output_dir: 'output-production' } } } }
it { is_expected.to eql("tmp/nanoc/#{hash_output}/giraffes") }
it { is_expected.to eql(Dir.getwd + "/tmp/nanoc/#{hash_output}/giraffes") }
end
end

Expand All @@ -47,22 +47,22 @@ def gen_hash(path)

context 'output dir is unspecified' do
let(:config_hash) { {} }
it { is_expected.to eql("tmp/nanoc/#{hash_output}/giraffes") }
it { is_expected.to eql(Dir.getwd + "/tmp/nanoc/#{hash_output}/giraffes") }
end

context 'output dir at root is specified' do
let(:config_hash) { { output_dir: 'output-default' } }
it { is_expected.to eql("tmp/nanoc/#{hash_output_default}/giraffes") }
it { is_expected.to eql(Dir.getwd + "/tmp/nanoc/#{hash_output_default}/giraffes") }
end

context 'output dir in given env is specified' do
let(:config_hash) { { environments: { staging: { output_dir: 'output-staging' } } } }
it { is_expected.to eql("tmp/nanoc/#{hash_output_staging}/giraffes") }
it { is_expected.to eql(Dir.getwd + "/tmp/nanoc/#{hash_output_staging}/giraffes") }
end

context 'output dir in other env is specified' do
let(:config_hash) { { environments: { production: { output_dir: 'output-production' } } } }
it { is_expected.to eql("tmp/nanoc/#{hash_output}/giraffes") }
it { is_expected.to eql(Dir.getwd + "/tmp/nanoc/#{hash_output}/giraffes") }
end
end
end
Expand Down