Skip to content

Commit

Permalink
Scripts: install global npm packages as root
Browse files Browse the repository at this point in the history
  • Loading branch information
miklschmidt committed Dec 20, 2024
1 parent 17c5cb1 commit 7414ba7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
16 changes: 6 additions & 10 deletions src/scripts/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,10 @@ report_status()
echo -e "\n\n###### $1"
}

update_npm()
update_package_managers()
{
report_status "Updating npm..."
npm install -g npm
}

update_pnpm()
{
report_status "Updating pnpm..."
npm install -g pnpm
report_status "Updating npm and pnpm..."
npm update -g npm pnpm
}

install_or_update_service_file()
Expand Down Expand Up @@ -87,11 +81,13 @@ ensure_pnpm_installation() {

install_global_npm_packages()
{
sudo=""
[ "$EUID" -ne 0 ] && sudo="sudo"
# Install global packages
if ! which zx &> /dev/null; then
report_status "Installing global npm package requirements..."
# Pass PNPM_HOME to the subshell
sudo -u "${RATOS_USERNAME}" npm install -g xz
$sudo npm install -g xz
fi
}

Expand Down
3 changes: 2 additions & 1 deletion src/scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ disable_telemetry
install_udev_rule
install_cli
symlink_configuration
install_or_update_service_file
install_or_update_service_file
install_global_npm_packages
7 changes: 3 additions & 4 deletions src/scripts/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@ maybe_truncate_log()
verify_ready
verify_users
maybe_truncate_log
update_npm
update_pnpm
install_hooks
ensure_pnpm_installation
ensure_service_permission
ensure_sudo_command_whitelisting
ensure_pnpm_installation
install_hooks
update_package_managers
pnpm_install
install_global_npm_packages
install_cli
Expand Down

0 comments on commit 7414ba7

Please sign in to comment.