Skip to content

Commit 36ef762

Browse files
committed
Lock command: update specifies dependencies
1 parent 04d93e4 commit 36ef762

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

src/cli.cr

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ module Shards
4848
when "list"
4949
Commands::List.run(path, tree: args.includes?("--tree"))
5050
when "lock"
51-
Commands::Lock.run(path,
51+
Commands::Lock.run(
52+
path,
53+
args.reject(&.starts_with?("--")),
5254
print: args.includes?("--print"),
5355
update: args.includes?("--update")
5456
)

src/commands/lock.cr

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,24 @@ require "../solver"
44
module Shards
55
module Commands
66
class Lock < Command
7-
def run(print = false, update = false)
7+
def run(shards, print = false, update = false)
88
Shards.logger.info { "Resolving dependencies" }
99

1010
solver = Solver.new(spec)
11-
solver.locks = locks if !update && lockfile?
11+
12+
if lockfile?
13+
if update
14+
# update selected dependencies to latest possible versions, but
15+
# avoid to update unspecified dependencies, if possible:
16+
unless shards.empty?
17+
solver.locks = locks.reject { |d| shards.includes?(d.name) }
18+
end
19+
else
20+
# install must be as conservative as possible:
21+
solver.locks = locks
22+
end
23+
end
24+
1225
solver.prepare(development: !Shards.production?)
1326

1427
if solution = solver.solve

0 commit comments

Comments
 (0)