Created
March 13, 2013 15:00
-
-
Save sters/5152952 to your computer and use it in GitHub Desktop.
Script to compile some script language. for me. I use notepad++ and NppExec plugin. this plugin can run to any shell program.
But don't process according to file extension, so write this script in process according to file extension.
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
################################################### | |
# | |
# Any file compile run on shell. | |
# Can't some file joint compile that regret... | |
# | |
# target : win32, Ruby | |
# necessary : Ruby # can simple file name processing and command run. | |
# gem/win32console # color set | |
# | |
# support : haml It mean, "can compile command run". | |
# sass If you not installed these commands, can't compile. | |
# scss Necessary these commands. | |
# TypeScript (use gem, npm, or other...) | |
# CoffeeScript | |
# Go | |
# | |
#------------------------- | |
# if use notepad++, use this command on NppExec | |
#------------------------- | |
# NPP_SAVE | |
# cmd /c "ruby npp_myfile_compiler.rb $(FULL_CURRENT_PATH)" | |
################################################### | |
require "win32console" | |
file_path = ARGV[0] | |
current_dir = File.dirname(file_path) | |
file_ext = File.extname(file_path) | |
file_name = File.basename(file_path, "#{file_ext}") | |
file_path_noext = File.absolute_path(file_name, current_dir) | |
puts "\e[32m[#{file_ext}] start\e[0m" | |
puts "\tpath dir : #{current_dir}" | |
puts "\t file : #{file_name}" | |
puts "\t ext : #{file_ext}" | |
print "\tResult : " | |
puts case file_ext | |
# command exec | |
when ".haml" | |
`haml -E UTF-8 -f html5 "#{file_path}" "#{file_path_noext}.html"` | |
when ".scss" | |
`sass --style compressed --scss "#{file_path}" --cache-location "C:\Users/%USERNAME%/.sass-cache" "#{file_path_noext}.css"` | |
when ".sass" | |
`sass --style compressed "#{file_path}" --cache-location "C:\Users/%USERNAME%/.sass-cache" "#{file_path_noext}.css"` | |
when ".ts" | |
`tsc --declaration --out "#{file_path_noext}.js" "#{file_path}"` | |
when ".coffee" | |
`coffee -c "#{file_path}"` | |
when ".go" | |
`go run "#{file_path}"` | |
end | |
puts "\e[32m[#{file_ext}] end\e[0m" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment