-
Notifications
You must be signed in to change notification settings - Fork 1
/
rake-plato.rb
65 lines (51 loc) · 1.67 KB
/
rake-plato.rb
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
require "rake"
require "albacore"
require "runcommandwithfail"
require "rake-nodejs"
class Plato
include Albacore::Task
include RunCommandWithFail
include Rake::DSL
# base location of the web project
# (default ".")
attr_accessor :base
# location where resulting html will be stored (relative to base)
# (default "buildreports/plato/")
attr_accessor :reports
# array of base location(s) of js source code to be linted
# (default ".")
attr_accessor :source
# array of file wildcards to exclude from processing (eg. ["lib/*", "plugin/*"])
# (default [])
attr_accessor :exclude
def initialize
@base = "."
@reports = "buildreports/plato"
buildscripts = File.dirname(__FILE__)
@plato = File.join(buildscripts, "node_modules/.bin", "plato.cmd")
unless @plato.nil?
@plato = File.expand_path(@plato) if File.exists?(@plato)
end
npm do |npm|
npm.base = buildscripts
end
Rake::Task[:npm].execute
Rake::Task[:npm].clear
super()
end
def execute
reports = File.expand_path(File.join(@base, @reports))
FileSystem.EnsurePath(reports)
source = @source
source = "." if @source.nil? || @source.length == 0
exclude = []
exclude << @exclude unless @exclude.nil? || @exclude.length == 0
@command = @plato
@working_directory = @base
params = []
params << "-d" << "\"" + reports + "\""
params << "-x" << "\"(#{exclude.join('|')})\"" if exclude.length > 0
params << "-r" << source
run_command("Plato", params)
end
end