From 6479af6a570e1a74925aafc7b2c591aeb693183d Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Thu, 3 Aug 2023 10:53:59 -0500 Subject: [PATCH] Preserve correct owner for `.bashrc` when configuring nodejs --- rattail_fabric2/nodejs.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rattail_fabric2/nodejs.py b/rattail_fabric2/nodejs.py index 490cd2f..c35999c 100644 --- a/rattail_fabric2/nodejs.py +++ b/rattail_fabric2/nodejs.py @@ -2,7 +2,7 @@ ################################################################################ # # Rattail -- Retail Software Framework -# Copyright © 2010-2019 Lance Edgar +# Copyright © 2010-2023 Lance Edgar # # This file is part of Rattail. # @@ -46,6 +46,9 @@ def install(c, version=None, user=None): profile = os.path.join(home, '.profile') 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, '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"', **kwargs) append(c, profile, '[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"', **kwargs)