<commit_before># module: project
class Project < Thor
  include Thor::Actions

  @@excludes = %w(
    *.map
    .keep
  )

  desc 'build', 'Compile all Sass and CoffeeScript assets'
  def build
    thor "css:compile"
    thor "coffeescript:compile"
  end

  desc 'zip_release [OUTPUT_DIR]', 'Bundle the project into a zip file'
  def zip_release(output_dir = $root_dir.join('pkg'))
    require 'json'
    require 'zip'

    thor "project:build"

    pkg_dir  = Pathname.new output_dir
    dist_dir = $root_dir.join 'build'
    manifest = JSON.parse dist_dir.join('manifest.json').read
    version  = manifest['version']
    output   = pkg_dir.join "linkscan-v#{version}.zip"

    unless pkg_dir.directory?
      say_status 'mkdir', pkg_dir.to_s, :yellow
      Dir.mkdir pkg_dir
    end

    if output.file?
      say_status 'rm', output.to_s, :yellow
      output.unlink
    end

    Zip::File.open(output.to_s, Zip::File::CREATE) do |zip|
      files = Pathname.glob dist_dir.join('**', '**')

      files.delete_if do |f|
        matches = @@excludes.map {|pattern| f.basename.fnmatch(pattern) }
        matches.any?
      end

      files.each do |file|
        zip_path = file.to_s.gsub(dist_dir.to_s, 'hayfever')
        say_status 'add', zip_path, :yellow
        zip.add zip_path, file.to_s
      end
    end

    say_status 'saved', "Saved plugin to #{output.to_s}", :green
  end

  desc 'watch', 'Compile Sass and CoffeeScript files when they change'
  def watch
    require 'listen'

    listener = Listen.to $root_dir.expand_path.to_s do |modified, added, removed|
      if modified.any?
        commands = modified.map do |file|
          if File.fnmatch('*.scss', file)
            'css:compile'
          elsif File.fnmatch('*.coffee', file)
            'coffeescript:compile'
          else
            nil
          end
        end

        commands.uniq!
        commands.delete_if {|cmd| cmd.nil? } if commands.any?
        commands.each {|cmd| thor cmd } if commands.any?
      end
    end

    listener.start
    listener.ignore %r{\.git}
    listener.ignore %r{build/}
    listener.ignore %r{thor/}
    listener.ignore %r{pkg/}
    listener.ignore %r{test/}
    listener.ignore %r{thor/}

    Signal.trap 'INT' do
      say 'Stopping listener and exiting...', :yellow
      listener.stop
      exit 0
    end

    say 'Watching project folder for changes...', :yellow
    sleep
  end
end<commit_msg>Running javascript:bundle if coffeescript:compile is set to run in project:watch<commit_after># module: project
class Project < Thor
  include Thor::Actions

  @@excludes = %w(
    *.map
    .keep
  )

  desc 'build', 'Compile all Sass and CoffeeScript assets'
  def build
    thor "css:compile"
    thor "coffeescript:compile"
  end

  desc 'zip_release [OUTPUT_DIR]', 'Bundle the project into a zip file'
  def zip_release(output_dir = $root_dir.join('pkg'))
    require 'json'
    require 'zip'

    thor "project:build"

    pkg_dir  = Pathname.new output_dir
    dist_dir = $root_dir.join 'build'
    manifest = JSON.parse dist_dir.join('manifest.json').read
    version  = manifest['version']
    output   = pkg_dir.join "linkscan-v#{version}.zip"

    unless pkg_dir.directory?
      say_status 'mkdir', pkg_dir.to_s, :yellow
      Dir.mkdir pkg_dir
    end

    if output.file?
      say_status 'rm', output.to_s, :yellow
      output.unlink
    end

    Zip::File.open(output.to_s, Zip::File::CREATE) do |zip|
      files = Pathname.glob dist_dir.join('**', '**')

      files.delete_if do |f|
        matches = @@excludes.map {|pattern| f.basename.fnmatch(pattern) }
        matches.any?
      end

      files.each do |file|
        zip_path = file.to_s.gsub(dist_dir.to_s, 'hayfever')
        say_status 'add', zip_path, :yellow
        zip.add zip_path, file.to_s
      end
    end

    say_status 'saved', "Saved plugin to #{output.to_s}", :green
  end

  desc 'watch', 'Compile Sass and CoffeeScript files when they change'
  def watch
    require 'listen'

    listener = Listen.to $root_dir.expand_path.to_s do |modified, added, removed|
      if modified.any?
        commands = modified.map do |file|
          if File.fnmatch('*.scss', file)
            'css:compile'
          elsif File.fnmatch('*.coffee', file)
            'coffeescript:compile'
          else
            nil
          end
        end

        commands.uniq!
        commands.delete_if {|cmd| cmd.nil? } if commands.any?
        commands.push('javascript:bundle') if commands.include?('coffeescript:compile')
        commands.each {|cmd| thor cmd } if commands.any?
      end
    end

    listener.start
    listener.ignore %r{\.git}
    listener.ignore %r{build/}
    listener.ignore %r{thor/}
    listener.ignore %r{pkg/}
    listener.ignore %r{test/}
    listener.ignore %r{thor/}

    Signal.trap 'INT' do
      say 'Stopping listener and exiting...', :yellow
      listener.stop
      exit 0
    end

    say 'Watching project folder for changes...', :yellow
    sleep
  end
end
{'fraction_non_alphanumeric': 0.11771771771771772, 'fraction_numerical': 0.0004004004004004004, 'mean_word_length': 2.462231462231462, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6138211', 'n_tokens_mistral': 1715, 'n_tokens_neox': 1615, 'n_words': 421}