Allow specifying which version of nodejs to install

This commit is contained in:
Lance Edgar 2020-09-08 15:19:08 -05:00
parent 08e030c8c7
commit 8f541c30b3

View file

@ -30,7 +30,7 @@ from rattail_fabric2 import append, exists
from rattail_fabric2.util import get_home_path
def install(c, user=None):
def install(c, version=None, user=None):
"""
Install nvm and node.js for given user, or else "connection" user.
"""
@ -50,7 +50,8 @@ def install(c, user=None):
append(c, profile, '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"', **kwargs)
append(c, 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:
c.sudo(cmd, user=user)
else: