Forked from EtienneLem/Compile CoffeeScript to JS.tmCommand
Created
May 13, 2013 16:58
-
-
Save iamjoshbinder/5569780 to your computer and use it in GitHub Desktop.
Compile CoffeeScript to JS
This file contains hidden or 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
| <?xml version="1.0" encoding="UTF-8"?> | |
| <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
| <plist version="1.0"> | |
| <dict> | |
| <key>beforeRunningCommand</key> | |
| <string>saveActiveFile</string> | |
| <key>command</key> | |
| <string>#!/usr/bin/env ruby | |
| # encoding: utf-8 | |
| in_assets_folder = ENV['TM_FILEPATH'].match(/assets\//) | |
| in_src_folder = ENV['TM_FILEPATH'].match(/src\/(.)+\.coffee/) | |
| # Automagically compile .coffee to .js if: | |
| # · Not in `assets/` folder | |
| # · Not direct child of `src/` | |
| if !in_assets_folder && !in_src_folder | |
| error = `coffee -c #{ENV['TM_FILEPATH']} 2>&1` | |
| if error == '' | |
| puts "✓ compiled #{ENV['TM_FILEPATH'].sub(/\.coffee$/, '.js')}" | |
| else | |
| puts "✗ #{error}" | |
| end | |
| # Automagically compile `src/abc.coffee` to `lib/abc.js` if: | |
| # · Is a direct child of `src/` | |
| elsif in_src_folder | |
| error = `coffee -co ../lib #{ENV['TM_FILEPATH']} 2>&1` | |
| if error == '' | |
| puts "✓ compiled to #{ENV['TM_FILEPATH'].sub(/\.coffee$/, '.js').sub(/src/, 'lib')}" | |
| else | |
| puts "✗ #{error}" | |
| end | |
| end</string> | |
| <key>input</key> | |
| <string>none</string> | |
| <key>keyEquivalent</key> | |
| <string>@s</string> | |
| <key>name</key> | |
| <string>Compile CoffeeScript to JS</string> | |
| <key>output</key> | |
| <string>showAsTooltip</string> | |
| <key>scope</key> | |
| <string>source.coffee</string> | |
| <key>uuid</key> | |
| <string>CC66EEF5-C60D-4EDC-AE88-500095838FE7</string> | |
| </dict> | |
| </plist> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment