Skip to content

Commit

Permalink
re-enabled ~ support in path resolver (#538)
Browse files Browse the repository at this point in the history
Co-authored-by: Johannes Müller <[email protected]>
  • Loading branch information
masukomi and straight-shoota authored Mar 22, 2022
1 parent a5d1c69 commit c477c37
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 8 additions & 0 deletions spec/integration/install_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,14 @@ describe "install" do
end
end

it "expands path and shows in debug info if missing" do
metadata = {dependencies: {nonexistent: {path: "~/nonexistent-path"}}}
with_shard(metadata) do
ex = expect_raises(FailedCommand) { run "shards install --no-color -v" }
ex.stdout.should contain(%(E: Failed no such path: #{Path.home.join("nonexistent-path")}))
end
end

it "install dependency with no shard.yml and show warning" do
metadata = {dependencies: {noshardyml: "0.1.0"}}
with_shard(metadata) do
Expand Down
4 changes: 2 additions & 2 deletions src/resolvers/path.cr
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module Shards
end

def read_spec(version = nil) : String?
spec_path = File.join(local_path, SPEC_FILENAME)
spec_path = File.join(expanded_local_path, SPEC_FILENAME)

if File.exists?(spec_path)
File.read(spec_path)
Expand All @@ -29,7 +29,7 @@ module Shards
end

private def expanded_local_path
File.expand_path(local_path).tap do |path|
File.expand_path(local_path, home: true).tap do |path|
raise Error.new("Failed no such path: #{path}") unless Dir.exists?(path)
end
end
Expand Down

0 comments on commit c477c37

Please sign in to comment.