Skip to content

Commit

Permalink
Add check that all source files include correct latvian address (#989)
Browse files Browse the repository at this point in the history
* Add check that all source files include correct latvian adress

* Rename and more details
  • Loading branch information
ShockwaveNN authored Jul 30, 2020
1 parent 1af5cc2 commit 01c706f
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# frozen_string_literal: true

excluded_source_paths = %w[/vendor/ /externs/ /jquery_native.js]

desc 'Find if any files do not containing license'
task :check_file_without_license do
license_header = 'Copyright Ascensio System'
all_js_files = Dir['./**/*.js']
excluded_pattern = %w[/vendor/ /externs/ /jquery_native.js]
files_without_license = []
all_js_files.each do |file|
next if excluded_pattern.any? { |exclude| file.include?(exclude) }
next if excluded_source_paths.any? { |exclude| file.include?(exclude) }

unless File.read(file).include?(license_header)
files_without_license << file
Expand All @@ -18,6 +19,23 @@ task :check_file_without_license do
end
end

desc 'Find if any files do not containing correct latvian adress'
task :check_file_without_latvian_adress do
latvian_address = 'LV-1050'
all_js_files = Dir['./**/*.js']
files_without_address = []
all_js_files.each do |file|
next if excluded_source_paths.any? { |exclude| file.include?(exclude) }

unless File.read(file).include?(latvian_address)
files_without_address << file
end
end
unless files_without_address.empty?
raise("Files without latvian address `#{latvian_address}`: #{files_without_address}")
end
end

desc 'Find files without LF ending'
task :check_file_without_lf_ending do
all_files = Dir['./**/*.js']
Expand Down Expand Up @@ -49,4 +67,5 @@ task :check_source_files do
Rake::Task['check_file_without_license'].invoke
Rake::Task['check_file_without_lf_ending'].invoke
Rake::Task['check_file_trailing_newline'].invoke
Rake::Task['check_file_without_latvian_adress'].invoke
end

0 comments on commit 01c706f

Please sign in to comment.