Skip to content

Instantly share code, notes, and snippets.

@tstone
Created September 21, 2012 05:08
Show Gist options
  • Save tstone/3759820 to your computer and use it in GitHub Desktop.
Save tstone/3759820 to your computer and use it in GitHub Desktop.
A ruby script to make running coffeelint a bit easier
#!/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