diff options
author | Jacques Erasmus <jerasmus@gitlab.com> | 2019-10-15 01:13:40 +0300 |
---|---|---|
committer | Evan Read <eread@gitlab.com> | 2019-10-15 01:13:40 +0300 |
commit | 21cc1fef11349417ed515557748369cfb235fc81 (patch) | |
tree | 80d2aa5f80f77da64871987030f47e3c14492b66 /commands/frontend.rb | |
parent | 179a601f70c3ca693911895814b271130d68df4a (diff) |
Add support for modern JS
Added rollup to the project
Diffstat (limited to 'commands/frontend.rb')
-rw-r--r-- | commands/frontend.rb | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/commands/frontend.rb b/commands/frontend.rb new file mode 100644 index 00000000..e3b91385 --- /dev/null +++ b/commands/frontend.rb @@ -0,0 +1,40 @@ +usage 'frontend [options]' +aliases :ds, :stuff +summary 'uses nanoc cli to execute frontend related tasks' +description 'This command is used by the Nanoc CLI to bundle the JavaScript.' + +flag :h, :help, 'show help for this command' do |value, cmd| + puts cmd.help + exit 0 +end +run do |opts, args, cmd| + + puts '--------------------------------' + + if check_requirements? + puts 'Compiling JavaScript...' + + system('yarn install') + + system('yarn bundle') + end +end + +def check_requirements? + puts 'Checking requirements...' + + has_requirements = command_exists?('node') && command_exists?('yarn') + + unless has_requirements + puts 'Your system may be missing some requirements.' + puts 'Please refer to the installation instructions for more details:' + puts 'https://gitlab.com/gitlab-org/gitlab-docs/blob/master/README.md' + end + has_requirements +end + +def command_exists?(command) + exists = system("which #{command} > /dev/null 2>&1") + puts "🚨 #{command} is not installed!" unless exists + exists +end |