Class: PackageJson::Managers::YarnClassicLike

Inherits:
Base
  • Object
show all
Defined in:
lib/package_json/managers/yarn_classic_like.rb

Instance Attribute Summary

Attributes inherited from Base

#binary

Instance Method Summary collapse

Methods inherited from Base

#add!, #install!, #remove!, #run!, #version

Constructor Details

#initialize(package_json) ⇒ YarnClassicLike

Returns a new instance of YarnClassicLike.



4
5
6
# File 'lib/package_json/managers/yarn_classic_like.rb', line 4

def initialize(package_json)
  super(package_json, binary_name: "yarn")
end

Instance Method Details

#add(packages, type: :production) ⇒ Object

Adds the given packages



19
20
21
# File 'lib/package_json/managers/yarn_classic_like.rb', line 19

def add(packages, type: :production)
  raw("add", [package_type_install_flag(type)].compact + packages)
end

#install(frozen: false) ⇒ Object

Installs the dependencies specified in the ‘package.json` file



9
10
11
# File 'lib/package_json/managers/yarn_classic_like.rb', line 9

def install(frozen: false)
  raw("install", with_frozen_flag(frozen))
end

#native_exec_command(script_name, args = []) ⇒ Object



46
47
48
49
50
51
# File 'lib/package_json/managers/yarn_classic_like.rb', line 46

def native_exec_command(
  script_name,
  args = []
)
  [File.join(fetch_bin_path, script_name), *args]
end

#native_install_command(frozen: false) ⇒ Object

Provides the “native” command for installing dependencies with this package manager for embedding into scripts



14
15
16
# File 'lib/package_json/managers/yarn_classic_like.rb', line 14

def native_install_command(frozen: false)
  build_full_cmd("install", with_frozen_flag(frozen))
end

#native_run_command(script_name, args = [], silent: false) ⇒ Object

Provides the “native” command for running the script with args for embedding into shell scripts



38
39
40
41
42
43
44
# File 'lib/package_json/managers/yarn_classic_like.rb', line 38

def native_run_command(
  script_name,
  args = [],
  silent: false
)
  build_full_cmd("run", build_run_args(script_name, args, silent: silent))
end

#remove(packages) ⇒ Object

Removes the given packages



24
25
26
# File 'lib/package_json/managers/yarn_classic_like.rb', line 24

def remove(packages)
  raw("remove", packages)
end

#run(script_name, args = [], silent: false) ⇒ Object

Runs the script assuming it is defined in the ‘package.json` file



29
30
31
32
33
34
35
# File 'lib/package_json/managers/yarn_classic_like.rb', line 29

def run(
  script_name,
  args = [],
  silent: false
)
  raw("run", build_run_args(script_name, args, silent: silent))
end