forked from instructure/canvas-lms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjs.rake
More file actions
63 lines (52 loc) · 1.8 KB
/
Copy pathjs.rake
File metadata and controls
63 lines (52 loc) · 1.8 KB
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 'json'
namespace :js do
desc "Build client_apps"
task :build_client_apps do
require 'config/initializers/client_app_symlinks'
Dir.glob('./client_apps/*/').each do |app_dir|
app_name = File.basename(app_dir)
Dir.chdir(app_dir) do
puts "Building client app '#{app_name}'"
if File.exists?('./package.json')
output = `yarn install || npm install` rescue `npm cache clean && npm install`
unless $?.exitstatus == 0
puts "INSTALL FAILURE:\n#{output}"
raise "Package installation failure for client app #{app_name}"
end
end
puts "\tRunning 'npm run build'..."
output = `./script/build`
unless $?.exitstatus == 0
puts "BUILD FAILURE:\n#{output}"
raise "Build script failed for client app #{app_name}"
end
puts "Client app '#{app_name}' was built successfully."
end
end
maintain_client_app_symlinks
end
desc "Build webpack js"
task :webpack do
if ENV['RAILS_ENV'] == 'production' || ENV['USE_OPTIMIZED_JS'] == 'true' || ENV['USE_OPTIMIZED_JS'] == 'True'
puts "--> Building PRODUCTION webpack bundles"
`npm run webpack-production`
else
puts "--> Building DEVELOPMENT webpack bundles"
`npm run webpack-development`
end
raise "Error running js:webpack: \nABORTING" if $?.exitstatus != 0
end
desc "Ensure up-to-date node environment"
task :npm_install do
puts "node is: #{`node -v`.strip} (#{`which node`.strip})"
output = `yarn install || npm install`
unless $?.success?
puts output
raise 'error running yarn install'
end
end
desc "Run Gulp Rev, for fingerprinting assets"
task :gulp_rev do
raise "Error reving files" unless system('node_modules/.bin/gulp rev')
end
end