<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>beforeRunningCommand</key>
	<string>nop</string>
	<key>command</key>
    <string>#!/usr/bin/env ruby

nvmdir = File.expand_path('~/.nvm')
localdir = "/usr/local/bin/"
if File.directory?nvmdir then
    cartos = Dir.glob(nvmdir + '/*/bin/mapnik-render.js')
    carto = cartos.pop() if cartos
    node = carto.gsub('/bin/mapnik-render.js', '/bin/node')
elsif File.exist?localdir + "mapnik-render.js"
    carto = localdir + "mapnik-render.js"
    node = localdir + "node"
end

if carto
    `#{node} #{carto} #{ENV['TM_FILEPATH']} /tmp/test.png`
else
    puts 'node and mapnik-render.js could not be found'
end
</string>
	<key>input</key>
	<string>none</string>
	<key>keyEquivalent</key>
	<string>^~@p</string>
	<key>name</key>
	<string>Preview</string>
	<key>output</key>
	<string>showAsHTML</string>
	<key>scope</key>
	<string>source.mml</string>
	<key>uuid</key>
	<string>4A0B3C2B-5F11-4D70-AFF4-EC4A4A042D66</string>
</dict>
</plist>
