Nic*_*mou 3 shell-script node.js
我正在编写一个脚本,首先检查当前是否安装了 Node,如果没有,它将安装最新版本的 Node。如果已安装,则它将继续执行另一个功能以对其进行更新。
我目前的脚本:
#!/bin/bash
function isNodeInstalled() {
clear
echo "Checking if Node is installed ..."
if command --version node &>/dev/null; then
echo "Installing Node ..."
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install nodejs -y
echo "Node has been installed."
sleep 5
updateNode
else
echo "Node has already been installed."
sleep 5
updateNode
fi
}
Run Code Online (Sandbox Code Playgroud)
if which node > /dev/null
then
echo "node is installed, skipping..."
else
# add deb.nodesource repo commands
# install node
fi
Run Code Online (Sandbox Code Playgroud)