Created
September 21, 2012 05:08
-
-
Save tstone/3759820 to your computer and use it in GitHub Desktop.
A ruby script to make running coffeelint a bit easier
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
#!/usr/bin/env ruby | |
# | |
# Use: | |
# | |
# => cfl | |
# => cfl all | |
# => cfl last | |
# => cfl last 3 | |
# | |
class LintRunner | |
attr_reader :files | |
def initialize | |
# Find all coffee files, sort by last modified time | |
@files = Dir['**/*.coffee'].sort_by { |f| File.mtime(f) } | |
@printed = 0 | |
end | |
def lint(index) | |
if (@printed > 0) then | |
puts "----------------------------------------------------------------------------" | |
end | |
file = @files[index] | |
system "coffeelint #{file}" | |
@printed = @printed + 1 | |
end | |
end | |
runner = LintRunner.new | |
# Lint based on args | |
if ARGV.length > 0 then | |
if ARGV[0] == 'last' then | |
if ARGV[1] then | |
ARGV[1].to_i.times {|i| runner.lint i } | |
else | |
runner.lint 0 | |
end | |
elsif ARGV[0] == 'all' then | |
runner.files.length.times {|i| runner.lint i } | |
elsif ARGV[0] == 'list' then | |
runner.files.each {|f| puts " #{f}" } | |
end | |
else | |
runner.lint 0 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment