Sha256: b9dbf13183bfdcd842d9ba40ad2977aa0f68e93f4b7dad61de4937c41b30a542

Contents?: true

Size: 1.18 KB

Versions: 5

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true

namespace :yarn do
	desc 'Load the .bowerrc file and setup the environment for other tasks.'
	task :environment do
		@yarn_package_root = SITE_ROOT + "lib/components"
		@yarn_install_root = SITE_ROOT + "public/_components"
	end
	
	desc 'Update the bower packages and link into the public directory.'
	task :update => :environment do
		require 'fileutils'
		require 'utopia/path'
		
		@yarn_package_root.children.select(&:directory?).collect(&:basename).each do |package_directory|
			install_path = @yarn_install_root + package_directory
			package_path = @yarn_package_root + package_directory
			dist_path = package_path + 'dist'
			
			FileUtils::Verbose.rm_rf install_path
			FileUtils::Verbose.mkpath(install_path.dirname)
			
			# If a package has a dist directory, we only symlink that... otherwise we have to do the entire package, and hope that bower's ignore was setup correctly:
			if File.exist? dist_path
				link_path = Utopia::Path.shortest_path(dist_path, install_path)
			else
				link_path = Utopia::Path.shortest_path(package_path, install_path)
			end
			
			FileUtils::Verbose.cp_r File.expand_path(link_path, install_path), install_path
		end
	end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
utopia-2.12.4 setup/site/tasks/yarn.rake
utopia-2.12.3 setup/site/tasks/yarn.rake
utopia-2.12.2 setup/site/tasks/yarn.rake
utopia-2.12.1 setup/site/tasks/yarn.rake
utopia-2.12.0 setup/site/tasks/yarn.rake