Add nodejs.install() for "typical" nvm / node.js install

also some related tweaks, necessary for that
This commit is contained in:
Lance Edgar 2019-09-23 15:26:28 -05:00
parent 21bdc2b391
commit e81f4afa8f
2 changed files with 72 additions and 1 deletions

View file

@ -119,7 +119,10 @@ def append(c, filename, text, use_sudo=False, partial=False, escape=True,
and contains(c, filename, regex, use_sudo=use_sudo, escape=False,
shell=shell)):
continue
line = line.replace("'", r"'\\''") if escape else line
if escape:
line = line.replace("'", r"'\\''") # TODO: does this one even work?
line = line.replace('"', r'\"')
line = line.replace('$', r'\$')
func("""bash -c "echo '%s' >> %s" """ % (line, _expand_path(c, filename)))
@ -178,3 +181,14 @@ def _expand_path(c, path):
This function is derived from one copied from fabric v1.
"""
return path if is_win(c) else '"$(echo %s)"' % path
def get_home_path(c, user=None):
"""
Retrieve the path to the home folder for the given user, or else the
"connection" user.
"""
user = user or c.user
home = c.run('getent passwd {} | cut -d: -f6'.format(user)).stdout.strip()
home = home.rstrip('/')
return home