Class: Recipes::Node

Inherits:
Rails::AppBuilder
  • Object
show all
Defined in:
lib/potassium/recipes/node.rb

Constant Summary collapse

NODE_VERSION =
Potassium::NODE_VERSION

Instance Method Summary collapse

Instance Method Details

#createObject



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/potassium/recipes/node.rb', line 8

def create
  info "Using node version LTS #{NODE_VERSION}"
  create_file '.node-version', NODE_VERSION, force: true
  after(:vite_install) do
    json_file = File.read(Pathname.new("package.json"))
    js_package = JSON.parse(json_file)
    js_package["engines"] = { "node" => "#{NODE_VERSION}.x" }
    json_string = JSON.pretty_generate(js_package)
    create_file 'package.json', json_string, force: true
  end
end