33# This Rakefile is to be invoked with the `rake` Ruby Gem. It's best if the that
44# Gem is installed using Bundler and the included Gemfile.
55#
6- # This file will act as the canonical builder for the JavaScript/CoffeeScript
7- # and CSS/SCSS 'dynamic' files, which are compiled into static/js/ and
8- # static/css/ respectively.
9-
10- #TODO<drew.pirrone.brusse@gmail>: Make sure the above description is correct and
11- # complete.
6+ # This file will act as the canonical builder for all common build operations;
7+ # * Compiling SCSS into CSS
8+ # * Compiling CoffeeScript into JavaScript
9+ # * Aggregating project description and download package metadata
10+ # * Deploying the static site to S3
11+ #
12+ # Additionally, this file can be used by developers to
13+ # * Watch changes in the dynamic/ directory and automatically recompile CSS/JS
14+ # * Watch changes in the content/ directory and automatically rebuild the site
15+ #
16+ # Running `rake` or `rake -T` will output a list of useful commands and
17+ # descriptions thereof.
1218
1319require_relative 'rake_libs/compile_js'
1420require_relative 'rake_libs/compile_css'
@@ -28,7 +34,36 @@ directory "#{$js_dest}"
2834directory "#{ $css_dest} "
2935directory "#{ $cache_dir} "
3036
31- #TODO<drew.pirrone.brusse@gmail>: Check to make sure Hugo's version is >= 0.15
37+
38+ ######################################################################
39+ ### Version Checks
40+
41+ min_hugo_version = "0.16"
42+ min_ruby_version = "2.2.5"
43+
44+ # Check if Ruby is up to date
45+ if Gem ::Version . new ( min_ruby_version ) > Gem ::Version . new ( RUBY_VERSION )
46+ Kernel . abort ( "ERROR: An old version of Ruby (#{ RUBY_VERSION } ) is in use.\n " \
47+ " Please upgrade this tool to at least version " \
48+ "#{ min_ruby_version } .\n " )
49+ end
50+
51+
52+ # Check if Hugo is installed, and confirm it's up to date.
53+ if ( `which hugo` . empty? )
54+ Kernel . abort ( "ERROR: No version of Hugo is installed.\n " \
55+ " Please install the latest version of Hugo -- gohugo.io/" )
56+ end
57+
58+ # This regex looks for e.g. "v0.16" -- matching only the "0.16" -- and then we
59+ # extract the first string from the returned MatchData with the `[0]`
60+ hugo_version = /(?<=v)\d +\. \d +/ . match ( `hugo version` ) [ 0 ]
61+
62+ if Gem ::Version . new ( min_hugo_version ) > Gem ::Version . new ( hugo_version )
63+ Kernel . abort ( "ERROR: An old version of Hugo (#{ hugo_version } ) is in use.\n " \
64+ " Please upgrade this tool to at least version " \
65+ "#{ min_hugo_version } .\n " )
66+ end
3267
3368
3469######################################################################
0 commit comments