Skip to content

Commit

Permalink
linux installer script: use --global=false for npm
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffreyc-splunk committed Dec 14, 2023
1 parent a95e05a commit 55ce515
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
10 changes: 5 additions & 5 deletions internal/buildscripts/packaging/installer/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ ensure_not_installed() {
echo "Please uninstall auto instrumentation, or try running this script with the '--uninstall' option." >&2
exit 1
fi
if [ -n "$npm_path" ] && (cd $node_install_prefix && $npm_path ls @splunk/otel >/dev/null 2>&1); then
if [ -n "$npm_path" ] && (cd $node_install_prefix && $npm_path ls --global=false @splunk/otel >/dev/null 2>&1); then
echo "The @splunk/otel npm package is already installed in $node_install_prefix." >&2
echo "Please uninstall @splunk/otel, or try running this script with the '--uninstall' option." >&2
exit 1
Expand Down Expand Up @@ -569,8 +569,8 @@ install_node_package() {

echo "Installing the Node.js Auto Instrumentation package ..."
mkdir -p $node_install_prefix
echo "Running 'cd $node_install_prefix && $npm_path install $node_package_path':"
(cd $node_install_prefix && $npm_path install $node_package_path)
echo "Running 'cd $node_install_prefix && $npm_path install --global=false $node_package_path':"
(cd $node_install_prefix && $npm_path install --global=false $node_package_path)
}

create_zeroconfig_node() {
Expand Down Expand Up @@ -788,8 +788,8 @@ uninstall() {
fi
done

if command -v npm >/dev/null 2>&1 && (cd $node_install_prefix && npm ls @splunk/otel >/dev/null 2>&1); then
(cd $node_install_prefix && npm uninstall @splunk/otel)
if command -v npm >/dev/null 2>&1 && (cd $node_install_prefix && npm ls --global=false @splunk/otel >/dev/null 2>&1); then
(cd $node_install_prefix && npm uninstall --global=false @splunk/otel)
echo "Successfully uninstalled the @splunk/otel npm package from $node_install_prefix"
fi
}
Expand Down
6 changes: 5 additions & 1 deletion internal/buildscripts/packaging/tests/installer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,11 @@ def get_zc_method(container, distro, method):


def node_package_installed(container):
return container.exec_run(f"sh -l -c 'cd {NODE_PREFIX} && npm ls @splunk/otel'").exit_code == 0
cmd = f"sh -l -c 'cd {NODE_PREFIX} && npm ls --global=false @splunk/otel'"
print(f"Running '{cmd}':")
rc, output = container.exec_run(cmd)
print(output.decode("utf-8"))
return rc == 0


@pytest.mark.installer
Expand Down

0 comments on commit 55ce515

Please sign in to comment.