Preserve correct owner for .bashrc when configuring nodejs

This commit is contained in:
Lance Edgar 2023-08-03 10:53:59 -05:00
parent 075f931b5e
commit 6479af6a57

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2019 Lance Edgar # Copyright © 2010-2023 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -46,6 +46,9 @@ def install(c, version=None, user=None):
profile = os.path.join(home, '.profile') profile = os.path.join(home, '.profile')
kwargs = {'use_sudo': bool(user)} kwargs = {'use_sudo': bool(user)}
if kwargs['use_sudo']:
c.sudo(f'touch {profile}')
c.sudo(f'chown {user}: {profile}')
append(c, profile, 'export NVM_DIR="{}"'.format(nvm), **kwargs) append(c, profile, 'export NVM_DIR="{}"'.format(nvm), **kwargs)
append(c, profile, '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"', **kwargs) 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) append(c, profile, '[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"', **kwargs)