Sha256: 386aee3ed1ed909481e20a898b966a3e4918ff48a8b9dc3bb88c4f3107aa6d7a

Contents?: true

Size: 536 Bytes

Versions: 24

Compression:

Stored size: 536 Bytes

Contents

# frozen_string_literal: true

require 'json' unless defined?(JSON)

module Prettier
  PLUGIN = -File.expand_path('..', __dir__)
  BINARY = -File.join(PLUGIN, 'node_modules', 'prettier', 'bin-prettier.js')
  VERSION = -JSON.parse(File.read(File.join(PLUGIN, 'package.json')))['version']

  class << self
    def run(args)
      quoted = args.map { |arg| arg.start_with?('-') ? arg : "'#{arg}'" }
      command = "node #{BINARY} --plugin '#{PLUGIN}' #{quoted.join(' ')}"

      system({ 'RBPRETTIER' => '1' }, command)
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
prettier-1.2.1 lib/prettier.rb
prettier-1.2.0 lib/prettier.rb
prettier-1.1.0 lib/prettier.rb
prettier-1.0.1 lib/prettier.rb
prettier-1.0.0 lib/prettier.rb
prettier-1.0.0.pre.rc2 lib/prettier.rb
prettier-1.0.0.pre.rc1 lib/prettier.rb
prettier-0.22.0 lib/prettier.rb
prettier-0.21.0 lib/prettier.rb
prettier-0.20.1 lib/prettier.rb
prettier-0.20.0 lib/prettier.rb
prettier-0.19.1 lib/prettier.rb
prettier-0.19.0 lib/prettier.rb
prettier-0.18.2 lib/prettier.rb
prettier-0.18.1 lib/prettier.rb
prettier-0.18.0 lib/prettier.rb
prettier-0.17.0 lib/prettier.rb
prettier-0.16.0 lib/prettier.rb
prettier-0.15.1 lib/prettier.rb
prettier-0.15.0 lib/prettier.rb