summaryrefslogtreecommitdiff
path: root/tasks/spellcheck.rb
diff options
context:
space:
mode:
Diffstat (limited to 'tasks/spellcheck.rb')
-rw-r--r--tasks/spellcheck.rb22
1 files changed, 16 insertions, 6 deletions
diff --git a/tasks/spellcheck.rb b/tasks/spellcheck.rb
index 076173fa1d..a5c775eb83 100644
--- a/tasks/spellcheck.rb
+++ b/tasks/spellcheck.rb
@@ -16,19 +16,21 @@
#
namespace :spellcheck do
- task :fetch_common do
- sh "wget -q https://raw.githubusercontent.com/chef/chef_dictionary/master/chef.txt -O chef_dictionary.txt"
- end
-
- task run: %i{config_check fetch_common} do
+ task run: :prereqs do
sh 'cspell "**/*"'
end
desc "List the unique unrecognized words in the project."
- task unknown_words: %i{config_check fetch_common} do
+ task unknown_words: :prereqs do
sh 'cspell "**/*" --wordsOnly --no-summary | sort | uniq'
end
+ task prereqs: %i{cspell_check config_check fetch_common}
+
+ task :fetch_common do
+ sh "wget -q https://raw.githubusercontent.com/chef/chef_dictionary/master/chef.txt -O chef_dictionary.txt"
+ end
+
task :config_check do
require "json"
@@ -42,6 +44,14 @@ namespace :spellcheck do
abort "Failed to parse config file '#{config_file}', skipping spellcheck"
end
end
+
+ task :cspell_check do
+ require 'chef-utils'
+ ChefUtils.which('cspell') || abort(<<~INSTALL_CSPELL)
+ cspell is needed to run the spellcheck tasks. Run `npm install -g cspell` to install.
+ For more information: https://www.npmjs.com/package/cspell
+ INSTALL_CSPELL
+ end
end
desc "Run spellcheck on the project."