From 50a90c923502a2fe1485faee1636b32fa3e0ccd5 Mon Sep 17 00:00:00 2001 From: Kevin Soltysiak Date: Tue, 5 Dec 2023 16:00:49 +0100 Subject: [PATCH] Allow NPM use for install/build --- lib/tasks/jsbundling/build.rake | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/tasks/jsbundling/build.rake b/lib/tasks/jsbundling/build.rake index a115438..0988656 100644 --- a/lib/tasks/jsbundling/build.rake +++ b/lib/tasks/jsbundling/build.rake @@ -24,13 +24,15 @@ module Jsbundling def install_command return "bun install" if File.exist?('bun.lockb') || (tool_exists?('bun') && !File.exist?('yarn.lock')) - return "yarn install" if File.exist?('yarn.lock') || tool_exists?('yarn') + return "yarn install" if File.exist?('yarn.lock') || tool_exists?('yarn') && !File.exist?('package-lock.json') + return "npm install" if File.exist?('package-lock.json') || tool_exists?('npm') raise "jsbundling-rails: No suitable tool found for installing JavaScript dependencies" end def build_command return "bun run build" if File.exist?('bun.lockb') || (tool_exists?('bun') && !File.exist?('yarn.lock')) - return "yarn build" if File.exist?('yarn.lock') || tool_exists?('yarn') + return "yarn build" if File.exist?('yarn.lock') || tool_exists?('yarn') && !File.exist?('package-lock.json') + return "npm run build" if File.exist?('package-lock.json') || tool_exists?('npm') raise "jsbundling-rails: No suitable tool found for building JavaScript" end