Class: Fastlane::Helper::NpmHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/fastlane/plugin/npm/helper/npm_helper.rb

Class Method Summary collapse

Class Method Details

.find_root_dir(dir = Dir.pwd) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/fastlane/plugin/npm/helper/npm_helper.rb', line 8

def self.find_root_dir(dir = Dir.pwd)
  return dir if File.file?(File.join(dir, 'package.json'))
    
  parent_dir = File.expand_path("..", dir)
  return nil unless parent_dir != '/'

  find_root_dir parent_dir
end

.update_file_content(file_name:, search:, replace:) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/fastlane/plugin/npm/helper/npm_helper.rb', line 17

def self.update_file_content(file_name:, search:, replace:)
  text = File.read(file_name)
  new_contents = text.gsub(search, replace)

  # To write changes to the file, use:
  File.open(file_name, "w") {|file| file.puts new_contents }
end