-
-
Save cschneid/2174f1d854b2b6f9cf9e6b4619727327 to your computer and use it in GitHub Desktop.
Rake task to compile/copy elm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :elm do | |
Apps = [ "WorkspaceMain", "ManageSubscribersMain", "NotebookMain", "ResponsesMain" ] | |
JsFileName = "irn_elm.js" | |
JsOutputDir = "app/assets/javascripts" | |
desc "Updates packages, compiles the Elm code and copies it to #{JsOutputDir}" | |
task :compile_and_copy => [:package_install, :make, :copy] do | |
puts "Updated Packages, Compiled and copied Elm code to #{JsOutputDir}" | |
end | |
desc "Compiles the Elm code and copies it to #{JsOutputDir}" | |
task :offline_compile_and_copy => [:make, :copy] do | |
puts "Compiled and copied Elm code to #{JsOutputDir}" | |
end | |
desc "Runs package install and elm make" | |
task :compile => [:package_install, :make] do | |
puts "Updated Packages and Compiled Elm code to #{JsOutputDir}" | |
end | |
desc "Runs elm package install" | |
task :package_install do | |
Dir.chdir("../elm") do | |
unless system "elm package install" | |
puts "Failed to run 'elm package install'" | |
exit 1 | |
end | |
end | |
end | |
desc "Compiles the Elm code" | |
task :make do | |
Dir.chdir("../elm") do | |
files = Apps.map{|name| "src/#{name}.elm"}.join " " | |
puts "Compiling #{files} -> #{JsFileName}" | |
unless system "elm make #{files} --output #{JsFileName}" | |
puts "Failed to compile elm code #{files}" | |
exit 1 | |
end | |
end | |
end | |
desc "Copies the compiled Elm code to #{JsOutputDir}" | |
task :copy do | |
Dir.chdir("../elm") do | |
puts "Copying javascript #{JsFileName}" | |
FileUtils.cp(JsFileName, "../rails/#{JsOutputDir}") | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment