Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Allow rocco to find pygmentize on Windows #67

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion bin/rocco
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 11 additions & 1 deletion lib/rocco.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down