Skip to content

Commit

Permalink
Fix: Windows support (at least from a code perspective) (#10)
Browse files Browse the repository at this point in the history
* fix: windows support

* fix: ameba pinned
  • Loading branch information
mdwagner authored Jan 26, 2024
1 parent af25795 commit 591884e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion shard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ targets:
development_dependencies:
ameba:
github: crystal-ameba/ameba
version: ~> 1.0
version: 1.5.0
spectator:
gitlab: arctic-fox/spectator
version: ~> 0.11.3
7 changes: 6 additions & 1 deletion src/nox.cr
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ module Nox
def self.run(file : String)
procfile = Nox::Procfile.parse_file(file)
runner = Nox::Runner.new(procfile, output: STDOUT)
Signal::INT.trap { runner.interrupt_or_kill }
{% if compare_versions(Crystal::VERSION, "1.8.0") < 0 %}
{% raise "Windows requires >= 1.8.0" if flag?(:win32) %}
Signal::INT.trap { runner.interrupt_or_kill }
{% else %}
::Process.on_interrupt { runner.interrupt_or_kill }
{% end %}
runner.run
end
end
2 changes: 1 addition & 1 deletion src/nox/intercepting_io.cr
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ class Nox::InterceptingIO < IO
end

private def max_name_size : Int32
@@names.map(&.size).max
@@names.max_of(&.size)
end
end
12 changes: 10 additions & 2 deletions src/nox/process.cr
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,19 @@ class Nox::Process
def kill
with_process do |process|
print_bold "Attempting to kill..."
process.signal(Signal::KILL)
{% if compare_versions(Crystal::VERSION, "1.8.0") < 0 %}
{% if flag?(:win32) %}
process.terminate
{% else %}
process.signal(Signal::KILL)
{% end %}
{% else %}
process.terminate(graceful: false)
{% end %}
end
end

private def with_process
private def with_process(&)
if (process = @process) && process.exists?
yield process
end
Expand Down

0 comments on commit 591884e

Please sign in to comment.