Skip to content

Instantly share code, notes, and snippets.

@ox
Created October 31, 2012 23:17
Show Gist options
  • Save ox/3990566 to your computer and use it in GitHub Desktop.
Save ox/3990566 to your computer and use it in GitHub Desktop.
A Rakefile for making lispyscript projects. Needs 2 directories, src and bin
task default: [:make_all]
root = Dir.pwd
src = ENV["src"] || "src"; src_dir = File.join(root, src)
bin = ENV["bin"] || "bin"; bin_dir = File.join(root, bin)
main = ENV["main"] || "main"
def make(file_name, dir_out="bin")
Dir.mkdir(dir_out) unless File.directory?(dir_out)
res = `lispy #{file_name}.ls #{File.join(dir_out, file_name)}.js`
puts res unless res.empty?
end
def make_all(files, dir_out="bin")
files.each do |file|
make(File.basename(file, ".ls"), dir_out)
end
end
task :make_all do
Dir.chdir(src_dir) do |path|
puts "in #{path}"
make_all(Dir.glob("*.ls"), bin_dir)
end
end
task :clean do
sh "rm #{bin_dir}/*"
end
task test: [:make_all] do
sh "node #{File.join(root, bin, main)}.js"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment