Module: Jekyll::Esm::Managers::Yarn
- Defined in:
- lib/jekyll-esm/managers/yarn.rb
Class Method Summary collapse
- .add(package:, site:) ⇒ Object
- .dist(config) ⇒ Object
- .location(config) ⇒ Object
- .remove(packages:, site:) ⇒ Object
Class Method Details
.add(package:, site:) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/jekyll-esm/managers/yarn.rb', line 17 def self.add(package:, site:) stdout, stderr, status = Open3.capture3( "yarn add #{package}", chdir: File.(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 |
.dist(config) ⇒ Object
13 14 15 |
# File 'lib/jekyll-esm/managers/yarn.rb', line 13 def self.dist(config) config.dig('esm', 'dist') || location(config) || 'node_modules' end |
.location(config) ⇒ Object
9 10 11 |
# File 'lib/jekyll-esm/managers/yarn.rb', line 9 def self.location(config) config.dig('esm', 'yarn', 'dir') || 'node_modules' end |
.remove(packages:, site:) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/jekyll-esm/managers/yarn.rb', line 31 def self.remove(packages:, site:) stdout, stderr, status = Open3.capture3( "yarn remove #{packages}", chdir: File.(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 |