Allow specifying version of node.js to install

This commit is contained in:
Lance Edgar 2020-10-02 14:56:51 -05:00
parent a1af0b131e
commit 1868963b26

View file

@ -32,7 +32,7 @@ from fabric.contrib.files import append, exists
from rattail_fabric.util import get_home_path from rattail_fabric.util import get_home_path
def install(user=None): def install(version=None, user=None):
""" """
Install nvm and node.js for given user, or else "connection" user. Install nvm and node.js for given user, or else "connection" user.
""" """
@ -52,7 +52,8 @@ def install(user=None):
append(profile, '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"', **kwargs) append(profile, '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"', **kwargs)
append(profile, '[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"', **kwargs) append(profile, '[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"', **kwargs)
cmd = "bash -l -c 'nvm install node'" node = version or 'node'
cmd = "bash -l -c 'nvm install {}'".format(node)
if user: if user:
sudo(cmd, user=user) sudo(cmd, user=user)
else: else: