-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfetch_coffeescript.rb
More file actions
32 lines (26 loc) · 1.01 KB
/
fetch_coffeescript.rb
File metadata and controls
32 lines (26 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env ruby
require 'open-uri'
require 'fileutils'
COFFEE_URL = 'https://coffeescript.org/browser-compiler-legacy/coffeescript.js'
JS_PATH = 'lib/coffee_script/coffee-script.js'
GEMSPEC_PATH = 'coffee-script-source.gemspec'
SRC_RB_PATH = 'lib/coffee_script/source.rb'
puts 'Fetching latest coffee-script.js...'
js = URI.open(COFFEE_URL).read
File.write(JS_PATH, js)
puts 'Updated coffee-script.js.'
# Extract version from js file (look for vX.Y.Z in the first 10 lines)
version = js[/CoffeeScript Compiler v([\d.]+)/, 1]
raise 'Version not found in JS file!' unless version
puts "Detected CoffeeScript version: #{version}"
# Update gemspec version
gemspec = File.read(GEMSPEC_PATH)
gemspec.sub!(/spec.version = \"[\d.]+\"/, "spec.version = \"#{version}\"")
File.write(GEMSPEC_PATH, gemspec)
puts 'Updated gemspec version.'
# Update source.rb version
src_rb = File.read(SRC_RB_PATH)
src_rb.sub!(/VERSION = \"[\d.]+\"/, "VERSION = \"#{version}\"")
File.write(SRC_RB_PATH, src_rb)
puts 'Updated source.rb version.'
puts 'Done.'