Skip to content

Instantly share code, notes, and snippets.

@joshed-io
Created November 3, 2011 04:00
Show Gist options
  • Save joshed-io/1335745 to your computer and use it in GitHub Desktop.
Save joshed-io/1335745 to your computer and use it in GitHub Desktop.
Ruby script to automate running js2coffee against existing javascript folders
#!/usr/bin/env ruby
#run from within a folder containing your .js files
#each file will be converted to a .coffee file and copied to ../coffeescripts
#respects nested directory structure, creating what's necessary
Dir.glob("**/*.js").each do |file|
`mkdir -p ../coffeescripts/#{file_path = file.gsub(/[\/]?[^\/]*\.js/, "")}` unless file_path == ""
`js2coffee #{file} > ../coffeescripts/#{file.gsub(/\.js/, "")}.coffee`
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment