Skip to content

Commit

Permalink
fix: windows support
Browse files Browse the repository at this point in the history
  • Loading branch information
mdwagner committed Jan 26, 2024
1 parent af25795 commit 939f522
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
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
10 changes: 9 additions & 1 deletion src/nox/process.cr
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,15 @@ 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

Expand Down

0 comments on commit 939f522

Please sign in to comment.