-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
We use FNM instead of NVM. Reason: the setup seems easier with just `eval "$(fnm env)"`.
- Loading branch information
Showing
2 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
namespace :node_manager do | ||
module NodeManager | ||
def self.manager_path | ||
"#{File.expand_path("~")}/.fnm" | ||
end | ||
|
||
def self.setup_command | ||
"export PATH=\"#{manager_path}:$PATH\" && eval \"$(fnm env)\"" | ||
end | ||
end | ||
|
||
namespace :install do | ||
desc "Installs or updates a Node Manager" | ||
task :manager do | ||
path = NodeManager.manager_path | ||
|
||
begin | ||
sh NodeManager.setup_command | ||
rescue RuntimeError | ||
sh "curl -fsSL https://fnm.vercel.app/install | bash -s -- --install-dir \"#{path}\"" | ||
else | ||
sh "curl -fsSL https://fnm.vercel.app/install | bash -s -- --install-dir \"#{path}\" --skip-shell" | ||
end | ||
end | ||
|
||
task :node do | ||
begin | ||
sh "#{NodeManager.setup_command} && fnm use --install-if-missing" | ||
rescue StandardError | ||
Rake::Task["node_manager:install:manager"].invoke | ||
sh "#{NodeManager.setup_command} && fnm use --install-if-missing" | ||
end | ||
end | ||
end | ||
end |