Sha256: 75691e949b561d71a5a60914df0b03eb77ac07da29ce2dc69b5709f478cdab13

Contents?: true

Size: 1.06 KB

Versions: 12

Compression:

Stored size: 1.06 KB

Contents

# frozen_string_literal: true

require 'rake_factory'
require 'ruby_npm'

require_relative '../mixins/directoried'

module RakeNPM
  module Tasks
    class RunScript < RakeFactory::Task
      include Mixins::Directoried

      default_name :run_script
      default_description(RakeFactory::DynamicValue.new do |t|
        "Runs the NPM #{t.script} script"
      end)

      parameter :script, required: true
      parameter :arguments

      parameter :color, default: 'always'

      parameter :environment, default: {}

      parameter :directory

      action do |task|
        logged_directory = task.directory || '.'
        puts(
          "Running NPM script: '#{task.script}' " \
          "in directory: '#{logged_directory}'..."
        )

        in_directory(task.directory) do
          RubyNPM.run_script(
            {
              script: task.script,
              arguments: task.arguments,
              color: task.color
            },
            {
              environment: task.environment
            }
          )
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
rake_npm-0.3.0.pre.2 lib/rake_npm/tasks/run_script.rb
rake_npm-0.3.0.pre.1 lib/rake_npm/tasks/run_script.rb
rake_npm-0.2.0 lib/rake_npm/tasks/run_script.rb
rake_npm-0.1.0.pre.18 lib/rake_npm/tasks/run_script.rb
rake_npm-0.1.0.pre.17 lib/rake_npm/tasks/run_script.rb
rake_npm-0.1.0.pre.16 lib/rake_npm/tasks/run_script.rb
rake_npm-0.1.0.pre.15 lib/rake_npm/tasks/run_script.rb
rake_npm-0.1.0.pre.14 lib/rake_npm/tasks/run_script.rb
rake_npm-0.1.0.pre.13 lib/rake_npm/tasks/run_script.rb
rake_npm-0.1.0.pre.12 lib/rake_npm/tasks/run_script.rb
rake_npm-0.1.0.pre.11 lib/rake_npm/tasks/run_script.rb
rake_npm-0.1.0.pre.10 lib/rake_npm/tasks/run_script.rb