Current section
Files
Jump to
Current section
Files
lib/mix/stylesheet_installer.ex
defmodule Mix.Tasks.EzCalendar.StylesheetInstaller do
@moduledoc false
###
# USED TO INSTALL THE DIFFERENT STYLESHEET TYPES
###
def install(ext) do
check_directory
do_assets(ext)
end
defp check_directory do
unless File.exists? "web/static/vendor" do
Mix.raise """
Can't find directory /web/static/vendor/, make sure you are in the root directory of your phoenix application.
"""
end
end
defp do_assets ext do
IO.puts "#{IO.ANSI.green}copying #{ext} file to web/static/vendor/ez_calendar.#{ext}"
IO.puts "#{IO.ANSI.white}Edit this to fit your needs of your application.\nYou can find all of the #{ext} selectors generated by the html helpers in this file"
from = Path.join([get_package_path, "lib/ez_calendar/html/assets", "ez_calendar.#{ext}"])
to = Path.join([File.cwd!, "web/static/vendor", "ez_calendar.#{ext}"])
File.cp_r from, to, fn(_, _) ->
IO.gets("#{IO.ANSI.red}This will overwrite the existing #{ext} file and destroy any canges you have made. Continue? (y/n): ") == "y\n"
end
end
defp get_package_path do
__ENV__.file
|> Path.dirname
|> String.split("/lib/mix")
|> hd
end
end