Sha256: 2544fb2f84353674117a44384e149aa7f52d3a2d8cf66f7b99dcb04c0999b8b9
Contents?: true
Size: 1.26 KB
Versions: 2
Compression:
Stored size: 1.26 KB
Contents
# frozen_string_literal: true module Jekyll module Esm module Managers module Npm class Error < StandardError; end def self.location(config) config.dig('esm', 'npm', 'dir') || 'node_modules' end def self.dist(config) config.dig('esm', 'dist') || location(config) || 'node_modules' end def self.add(package:, site:) stdout, stderr, status = Open3.capture3( "npm install #{package}", chdir: File.expand_path(File.join(site.source, '/')) ) if site.config.dig('esm', 'strict') runtime_error = stdout =~ /ERROR in|SyntaxError/ raise Error, stderr if stderr.size > 0 raise Error, stdout if !runtime_error.nil? end end def self.remove(packages:, site:) stdout, stderr, status = Open3.capture3( "npm uninstall #{packages}", chdir: File.expand_path(File.join(site.source, '/')) ) if site.config.dig('esm', 'strict') runtime_error = stdout =~ /ERROR in|SyntaxError/ raise Error, stderr if stderr.size > 0 raise Error, stdout if !runtime_error.nil? end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
jekyll-esm-0.3.1 | lib/jekyll-esm/managers/npm.rb |
jekyll-esm-0.3.0 | lib/jekyll-esm/managers/npm.rb |