diff --git a/bin/rocco b/bin/rocco index 71a67c6..96e98ef 100755 --- a/bin/rocco +++ b/bin/rocco @@ -47,8 +47,18 @@ ARGV.options { |o| o.parse! } or abort_with_note +if RUBY_PLATFORM =~ /(win|w)32$/ + # windows machine + path_dirs = ENV['PATH'].split(';') + found_pygmentize = path_dirs.any? { |dir| File.executable?("#{dir}/pygmentize.exe") } +else + # *nix system + path_dirs = ENV['PATH'].split(':') + found_pygmentize = path_dirs.any? { |dir| File.executable?("#{dir}/pygmentize") } +end + # Use http://pygments.appspot.com in case `pygmentize(1)` isn't available. -if ! ENV['PATH'].split(':').any? { |dir| File.exist?("#{dir}/pygmentize") } +if !found_pygmentize unless options[:webservice] $stderr.puts "pygmentize not in PATH; using pygments.appspot.com instead" options[:webservice] = true diff --git a/lib/rocco.rb b/lib/rocco.rb index 551a79d..ed36bdd 100644 --- a/lib/rocco.rb +++ b/lib/rocco.rb @@ -51,7 +51,17 @@ # Code is run through [Pygments](http://pygments.org/) for syntax # highlighting. If it's not installed, locally, use a webservice. -if !ENV['PATH'].split(':').any? { |dir| File.executable?("#{dir}/pygmentize") } +if RUBY_PLATFORM =~ /(win|w)32$/ + # windows machine + path_dirs = ENV['PATH'].split(';') + found_pygmentize = path_dirs.any? { |dir| File.executable?("#{dir}/pygmentize.exe") } +else + # *nix system + path_dirs = ENV['PATH'].split(':') + found_pygmentize = path_dirs.any? { |dir| File.executable?("#{dir}/pygmentize") } +end + +if !found_pygmentize warn "WARNING: Pygments not found. Using webservice." end