-
Notifications
You must be signed in to change notification settings - Fork 135
/
Copy pathbuild.rake
64 lines (56 loc) · 1.53 KB
/
build.rake
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
require 'rake/clean'
require 'yaml'
CLEAN.include('build')
CLEAN.include('resources')
CLEAN.include('public')
task :init do
sh("npm install")
end
task :run_hugo do
sh('npm run index')
sh('npm run hugo')
end
desc 'Check for title property on every md file'
task :check_for_title do
missing_title = []
Dir['content/**/*.md'].select {|file|
unless file.include? 'menu/index.md'
begin
thing = YAML.load_file(file)
title = thing['title']
unless title
missing_title.push(file)
end
rescue
missing_title.push(file)
end
end
}
if missing_title.length > 0
raise 'Title is mandatory for search functionality' + "\n" + missing_title.join("\n")
else
puts 'Success!!!'
end
end
desc 'Check for non-ascii chars in the md files'
task :exit_if_non_ascii_file_found do
error_files = []
Dir['content/**/*.md'].select {|filename|
contents = File.read(filename)
ascii_only = contents.ascii_only?
unless ascii_only
error_files.push(filename)
end
}
if error_files.length > 0
raise "Warning!!! Following files have non-ASCII chars in them. Please rectify them!" + "\n" + error_files.join('\n')
else
puts "No non-ASCII chars found!!!"
end
end
desc "build the documentation"
task :compile => [:clean, :init]
task :run_pre_tests => [:compile, :check_for_title, :exit_if_non_ascii_file_found]
task :build => [:compile, :run_hugo]
task :run_post_tests => ["static_checks:all"]
task :complete_build => [:run_pre_tests, :run_hugo, :run_post_tests]