Sha256: 69d08d72cb7d4f1f6d6f96e55d5653e2b6fec0353485004e50cc40ecb597b364

Contents?: true

Size: 1 KB

Versions: 8

Compression:

Stored size: 1 KB

Contents

module Retreaver
  class Compile

    class << self
      def perform
        Dir.chdir(root) do |f|
          run("npm install") unless Dir.exist?('./node_modules')
          # compile src
          run("npx --yes grunt-cli")
          output = 'vendor/assets/javascripts/'
          FileUtils.rm_rf(output)
          FileUtils.mkdir_p(output)
          Dir.glob('dist/*.js') { |f| FileUtils.cp(f, output) }
          # generate jsdocs
          output = 'vendor/documentation/javascripts/'
          FileUtils.rm_rf(output)
          run("./node_modules/.bin/jsdoc -c config/jsdocs.json")
        end
      end

      def run(command)
        puts(command)
        system_with_abort(command)
      end

      def system_with_abort(command, abort_message=nil)
        system(command, out: $stdout, err: :out)
        abort_message ||= "Error executing: '#{command}'"
        abort abort_message unless $?.success?
      end

      def root
        File.expand_path(File.join(__FILE__, '../../../'))
      end
    end

  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
retreaverjs-rails-0.2.25 lib/retreaverjs/compile.rb
retreaverjs-rails-0.2.24 lib/retreaverjs/compile.rb
retreaverjs-rails-0.2.23 lib/retreaverjs/compile.rb
retreaverjs-rails-0.2.22 lib/retreaverjs/compile.rb
retreaverjs-rails-0.2.21 lib/retreaverjs/compile.rb
retreaverjs-rails-0.2.20 lib/retreaverjs/compile.rb
retreaverjs-rails-0.2.19 lib/retreaverjs/compile.rb
retreaverjs-rails-0.2.18 lib/retreaverjs/compile.rb