Sha256: bb82deba3cf02f720b73e604b536cb7f5d6d8726ac74ed3ea8845c9dcb76d0fe

Contents?: true

Size: 1.49 KB

Versions: 3

Compression:

Stored size: 1.49 KB

Contents

require 'bundler'
require 'multi_json'
require 'open-uri'
Bundler::GemHelper.install_tasks

def say(line)
  puts "  \e[32m=>\e[0m #{line}"
end

def execute(banner, command)
  say(banner + "...")
  output = `#{command} 2>&1`
  unless $?.success?
    $stderr.puts("  \e[31mOops, something went wrong!\e[0m\n\n")
    $stderr.puts(output)
    exit(1)
  end
  output
end

desc 'Updates and releases the stylus-source gem'
task ship: :update do
  current_version = File.read('VERSION')
  execute 'commiting the VERSION file', "git add VERSION && git commit -m '#{current_version}'"
  Rake::Task['release'].invoke
end

desc "Downloads stylus into './vendor' and checks the latest released tag"
task :update do
  raw             = open('http://registry.npmjs.org/stylus') { |io| io.binmode.read }
  metadata        = MultiJson.load(raw)
  current_version = File.read('VERSION')
  version         = ENV['VERSION'] || metadata['dist-tags']['latest']
  tarball         = metadata['versions'][version]['dist']['tarball']

  say "Updating stylus source from #{current_version} to #{version}"

  execute 'cleaning up old files', 'rm -rf vendor'
  execute "download stylus #{version}", "wget #{tarball} -O stylus.tgz"
  execute "upacking stylus #{version}", 'tar -zxvf stylus.tgz'
  execute 'cleaning up', 'rm -rf stylus.tgz package/.npmignore'
  execute 'updating stylus dependencies', 'mv package vendor && cd vendor && npm install .'
  say 'updating VERSION file'
  File.open('VERSION', 'w') { |file| file.write(version) }
  say 'done!'
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
epuber-stylus-source-0.54.8 Rakefile
stylus-source-0.54.5 Rakefile
stylus-source-0.49.3 Rakefile