Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,13 @@ React Native applications commonly depend on certain Node modules. This workflow

Required Input Variables
- `$AC_SELECTED_NODE_VERSION`: Specifies the Node version to be installed. Defaults to: `lts`

## Running tests

Requires [RSpec](https://rspec.info) gem and Ruby standard library (Coverage, REXML). No Gemfile or Bundler needed.

```bash
ruby test/test_main.rb
```

A coverage report is printed at the end of each run.
29 changes: 17 additions & 12 deletions main.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
require 'os'
begin
require 'os'
rescue LoadError
end
require 'open3'

def env_has_key(key)
Expand All @@ -9,11 +12,6 @@ def get_version(component_version,config_version)
return config_version == nil ? component_version : config_version
end

component_node_version = env_has_key("AC_SELECTED_NODE_VERSION") || "lts"
config_node_version = env_has_key("AC_NODE_JS_VERSION")
selected_node_version = get_version(component_node_version,config_node_version)
puts "Selected node version is #{selected_node_version}"

def run_command(command)
puts "@@[command] #{command}"
status = nil
Expand All @@ -33,10 +31,17 @@ def run_command(command)
end
end

if OS.linux?
run_command("n #{selected_node_version}")
elsif OS.mac?
run_command("sudo n #{selected_node_version}")
else
abort("Unexpected OS")
if __FILE__ == $PROGRAM_NAME
component_node_version = env_has_key("AC_SELECTED_NODE_VERSION") || "lts"
config_node_version = env_has_key("AC_NODE_JS_VERSION")
selected_node_version = get_version(component_node_version,config_node_version)
puts "Selected node version is #{selected_node_version}"

if OS.linux?
run_command("n #{selected_node_version}")
elsif OS.mac?
run_command("sudo n #{selected_node_version}")
else
abort("Unexpected OS")
end
end
Loading