Sha256: d7ce492835897db6c1b08e1ea2c38aba1e43a9ed63abe4e5299dcbc214489411
Contents?: true
Size: 845 Bytes
Versions: 20
Compression:
Stored size: 845 Bytes
Contents
# frozen_string_literal: true module LearnTest module JsStrategy def js_package @js_package ||= File.exist?('package.json') ? Oj.load(File.read('package.json'), symbol_keys: true) : nil end def has_js_dependency?(dep) [:dependencies, :devDependencies].any? { |key| js_package[key] && js_package[key][dep] } end def modules_missing?(module_names) module_names.any? { |name| !File.exist?("node_modules/#{name}") } end def missing_dependencies? return true unless File.exist?('node_modules') [:dependencies, :devDependencies, :peerDependencies].any? do |dep_group| modules = js_package[dep_group] || {} modules_missing?(modules.keys) end end def npm_install run_install('npm install', npm_install: true) if missing_dependencies? end end end
Version data entries
20 entries across 20 versions & 1 rubygems