Module: OnContainer::Dev::NodeModulesOps
- Defined in:
- lib/on_container/dev/node_modules_ops.rb
Constant Summary collapse
- APP_PATH =
File. '.'
Instance Method Summary collapse
- #current_user_id ⇒ Object
- #ensure_node_modules_belong_to_current_user ⇒ Object
- #ensure_project_node_packages_are_installed ⇒ Object
- #make_node_modules_belong_to_current_user ⇒ Object
- #node_modules_belong_to_current_user? ⇒ Boolean
- #node_modules_owner_id ⇒ Object
- #node_modules_path ⇒ Object
Instance Method Details
#current_user_id ⇒ Object
18 19 20 |
# File 'lib/on_container/dev/node_modules_ops.rb', line 18 def current_user_id Etc.getpwuid.uid end |
#ensure_node_modules_belong_to_current_user ⇒ Object
31 32 33 34 35 |
# File 'lib/on_container/dev/node_modules_ops.rb', line 31 def ensure_node_modules_belong_to_current_user return if node_modules_belong_to_current_user? make_node_modules_belong_to_current_user end |
#ensure_project_node_packages_are_installed ⇒ Object
37 38 39 40 41 |
# File 'lib/on_container/dev/node_modules_ops.rb', line 37 def ensure_project_node_packages_are_installed ensure_node_modules_belong_to_current_user system 'yarn check --integrity || yarn install' end |
#make_node_modules_belong_to_current_user ⇒ Object
26 27 28 29 |
# File 'lib/on_container/dev/node_modules_ops.rb', line 26 def make_node_modules_belong_to_current_user target_ownership = "#{current_user_id}:#{current_user_id}" system "sudo chown -R #{target_ownership} #{node_modules_path}" end |
#node_modules_belong_to_current_user? ⇒ Boolean
22 23 24 |
# File 'lib/on_container/dev/node_modules_ops.rb', line 22 def node_modules_belong_to_current_user? node_modules_owner_id == current_user_id end |
#node_modules_owner_id ⇒ Object
14 15 16 |
# File 'lib/on_container/dev/node_modules_ops.rb', line 14 def node_modules_owner_id File.stat(node_modules_path).uid end |
#node_modules_path ⇒ Object
10 11 12 |
# File 'lib/on_container/dev/node_modules_ops.rb', line 10 def node_modules_path "#{APP_PATH}/node_modules" end |