Sha256: 7278a045540c811598bd6dfd1d4b6ac6fb5dde56fe99e5abd375fa1b508ac68d

Contents?: true

Size: 899 Bytes

Versions: 6

Compression:

Stored size: 899 Bytes

Contents

require 'pathname'

module Overcommit::Hook::PreCommit
  # Ensure the livescript source files are compiled.
  # Also make sure they're included in the commit.
  class EnsureLivescriptCompiled < Base
    def compiled_path ls
      ls.sub('livescript/', 'public/js/').sub(/\.ls$/, '.js')
    end

    def relative path
      Pathname.new(path).relative_path_from Pathname.getwd
    end

    def check_file lsfile
      compiled = compiled_path lsfile

      return "#{relative compiled}: older than #{relative lsfile}.
          $ ./compile_ls &" if File.stat(lsfile) > File.stat(compiled)

      return "#{relative lsfile}: compiled file not added.
          $ git add #{relative compiled}" unless modified_files.include? compiled
    end

    def run
      errs = applicable_files.map(&method(:check_file)).compact
      return :bad, errs.join('\n') unless errs.empty?
      :good
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
conjur-asset-ui-1.3.2 .git-hooks/pre_commit/ensure_livescript_compiled.rb
conjur-asset-ui-1.3.1 .git-hooks/pre_commit/ensure_livescript_compiled.rb
conjur-asset-ui-1.3.0 .git-hooks/pre_commit/ensure_livescript_compiled.rb
conjur-asset-ui-api-1.2.0 .git-hooks/pre_commit/ensure_livescript_compiled.rb
conjur-asset-ui-api-1.1.1 .git-hooks/pre_commit/ensure_livescript_compiled.rb
conjur-asset-ui-api-1.1.0 .git-hooks/pre_commit/ensure_livescript_compiled.rb