Class: CobraCommander::Dependencies::Yarn
- Inherits:
-
Object
- Object
- CobraCommander::Dependencies::Yarn
- Defined in:
- lib/cobra_commander/dependencies/yarn.rb
Overview
Yarn workspace components source for an umbrella
Defined Under Namespace
Classes: Package
Constant Summary collapse
- PACKAGE_FILE =
"package.json"
Instance Method Summary collapse
-
#initialize(root_path) ⇒ Yarn
constructor
A new instance of Yarn.
- #packages ⇒ Object
- #root ⇒ Object
Constructor Details
#initialize(root_path) ⇒ Yarn
Returns a new instance of Yarn.
15 16 17 |
# File 'lib/cobra_commander/dependencies/yarn.rb', line 15 def initialize(root_path) @root_path = Pathname.new(root_path) end |
Instance Method Details
#packages ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/cobra_commander/dependencies/yarn.rb', line 26 def packages @packages ||= begin output, = Open3.capture2("yarn workspaces --json info", chdir: @root_path.to_s) JSON.parse(JSON.parse(output)["data"]).map do |name, spec| Package.new( path: @root_path.join(spec["location"], PACKAGE_FILE).realpath, dependencies: spec["workspaceDependencies"], name: name ) end end end |
#root ⇒ Object
19 20 21 22 23 24 |
# File 'lib/cobra_commander/dependencies/yarn.rb', line 19 def root @root ||= Package.new( path: @root_path.join(PACKAGE_FILE).realpath, dependencies: packages.map(&:name) ) end |