install_files/specified_yarn.rb in bard-0.42.0 vs install_files/specified_yarn.rb in bard-0.43.0

- old
+ new

@@ -1,34 +1,31 @@ module SpecifiedYarn extend self - YARN_PATH = "node_modules/yarn/bin/yarn" + YARN_VERSION = "v1.22.0" + YARN_PATH = "tmp/yarn-#{YARN_VERSION}/bin/yarn.js" def ensure! install_yarn unless yarn_installed? - install_binstub unless binstub_installed? + install_binstub "bin/yarn install" end private def install_yarn - system(". ~/.nvm/nvm.sh && npm install yarn@#{version} --no-save") + system("wget -cO- https://github.com/yarnpkg/yarn/releases/download/#{YARN_VERSION}/yarn-#{YARN_VERSION}.tar.gz | tar -xz -C tmp/") end def install_binstub - system("cd bin && ln -s ../#{YARN_PATH}") + system("cd bin && ln -fs ../#{YARN_PATH}") end def yarn_installed? - File.exist?(YARN_PATH) && `#{YARN_PATH} --version`.chomp == version + File.exist?(YARN_PATH) && `bin/node #{YARN_PATH} --version`.chomp == YARN_VERSION[1..-1] end def binstub_installed? File.exist?("bin/yarn") - end - - def version - File.read("package.json")[/"yarn": "([0-9\.]+)"/, 1] end end