-
Notifications
You must be signed in to change notification settings - Fork 16
/
Rakefile
38 lines (31 loc) · 930 Bytes
/
Rakefile
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
33
34
35
36
37
38
require "bundler/gem_tasks"
require 'json'
def clean_ngannotate
`rm -rf node_modules`
end
def install_ngannotate
`npm install ng-annotate browserify`
end
def generate_ngannotate
`./node_modules/.bin/browserify ./node_modules/ng-annotate/build/es5/ng-annotate-main.js | sed -e's/module.exports = function ngAnnotate/window.annotate = function ngAnnotate/' > vendor/ngannotate.js`
end
def update_version
package = JSON.parse(File.open('./node_modules/ng-annotate/package.json').read)
write_version(package["version"])
end
def write_version(version)
text = <<-FILE
module Ngannotate
module Rails
VERSION = "#{version}"
end
end
FILE
File.open('lib/ngannotate/rails/version.rb', 'w') { |f| f.write text }
end
namespace :ngannotate do
desc "Build a new version of ngannotate-browserified.js"
task :build do
clean_ngannotate && install_ngannotate && generate_ngannotate && update_version
end
end