Skip to content

Commit

Permalink
Fix: shard.lock is always overwritten even when dependencies are up t…
Browse files Browse the repository at this point in the history
…o date (#370)
  • Loading branch information
waj committed Apr 30, 2020
1 parent 511f921 commit 5666481
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
12 changes: 12 additions & 0 deletions spec/integration/install_spec.cr
Expand Up @@ -366,6 +366,18 @@ describe "install" do
end
end

it "doesn't overwrite lockfile if no new dependencies are installed" do
metadata = {dependencies: {d: "*", c: "*"}}

with_shard(metadata) do
run "shards install"
File.touch "shard.lock", Time.utc(1900, 1, 1)
mtime = File.info("shard.lock").modification_time
run "shards install"
File.info("shard.lock").modification_time.should eq(mtime)
end
end

it "runs postinstall script" do
with_shard({dependencies: {post: "*"}}) do
output = run "shards install --no-color"
Expand Down
5 changes: 3 additions & 2 deletions src/commands/install.cr
Expand Up @@ -82,8 +82,9 @@ module Shards
end

private def outdated_lockfile?(packages)
a = packages.map { |x| {x.name, x.version} }
b = locks.map { |x| {x.name, x.requirement.as?(Version)} }
return true if packages.size != locks.size
a = packages.to_h { |x| {x.name, x.version} }
b = locks.to_h { |x| {x.name, x.requirement.as?(Shards::Version)} }
a != b
end
end
Expand Down

0 comments on commit 5666481

Please sign in to comment.