<commit_before>require 'fileutils'

namespace :npm do
  desc "Install npm packages"
  task :install do
    package_file = ::Rails.configuration.npm.package_file
    browserify_options = ::Rails.configuration.npm.browserify_options
    output_path = ::Rails.root.join(::Rails.configuration.npm.output_path)
    output_file = "npm-dependencies.js"
    output_file_path = output_path.join(output_file)

    Npm::Rails::TaskHelpers.create_file(output_path, output_file) unless File.exist?(output_file_path)

    Npm::Rails::PackageBundler.bundle(::Rails.root, package_file, ::Rails.env) do |packages, bundle_file_path|
      sh "cd #{ ::Rails.root }"
      sh "npm install --loglevel error #{ packages }"

      browserify = Npm::Rails::TaskHelpers.find_browserify(::Rails.root.join("node_modules"))
      browserify_command = "#{ browserify } #{ browserify_options } #{ bundle_file_path } > #{ output_file_path }"
      if Rails.env.production?
        browserify_command = "NODE_ENV=production #{ browserify_command }"
      end

      sh browserify_command
    end
  end
end

if ::Rails.configuration.npm.run_before_assets_precompile
  task "assets:precompile" => ["npm:install"]
end
<commit_msg>Remove `cd` as it cause issues in Debian<commit_after>require 'fileutils'

namespace :npm do
  desc "Install npm packages"
  task :install do
    package_file = ::Rails.configuration.npm.package_file
    browserify_options = ::Rails.configuration.npm.browserify_options
    output_path = ::Rails.root.join(::Rails.configuration.npm.output_path)
    output_file = "npm-dependencies.js"
    output_file_path = output_path.join(output_file)

    Npm::Rails::TaskHelpers.create_file(output_path, output_file) unless File.exist?(output_file_path)

    Npm::Rails::PackageBundler.bundle(::Rails.root, package_file, ::Rails.env) do |packages, bundle_file_path|
      sh "npm install --prefix #{ ::Rails.root } --loglevel error #{ packages }"

      browserify = Npm::Rails::TaskHelpers.find_browserify(::Rails.root.join("node_modules"))
      browserify_command = "#{ browserify } #{ browserify_options } #{ bundle_file_path } > #{ output_file_path }"
      if Rails.env.production?
        browserify_command = "NODE_ENV=production #{ browserify_command }"
      end

      sh browserify_command
    end
  end
end

if ::Rails.configuration.npm.run_before_assets_precompile
  task "assets:precompile" => ["npm:install"]
end

{'fraction_non_alphanumeric': 0.12023217247097844, 'fraction_numerical': 0.0, 'mean_word_length': 4.572748267898383, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '5586968', 'n_tokens_mistral': 791, 'n_tokens_neox': 765, 'n_words': 136}