diff --git a/packages/safe-chain/src/shell-integration/supported-shells/bash.js b/packages/safe-chain/src/shell-integration/supported-shells/bash.js index 3491bc7..ff2266b 100644 --- a/packages/safe-chain/src/shell-integration/supported-shells/bash.js +++ b/packages/safe-chain/src/shell-integration/supported-shells/bash.js @@ -141,9 +141,10 @@ function cygpathw(path) { } } -function getManualTeardownInstructions() { +/** @param {string} preamble */ +function buildManualInstructions(preamble) { const customDir = getSafeChainDir(); - const instructions = [`Remove the following line from your ~/.bashrc file:`]; + const instructions = [preamble]; if (customDir) { instructions.push( @@ -158,21 +159,12 @@ function getManualTeardownInstructions() { return instructions; } +function getManualTeardownInstructions() { + return buildManualInstructions(`Remove the following line from your ~/.bashrc file:`); +} + function getManualSetupInstructions() { - const customDir = getSafeChainDir(); - const instructions = [`Add the following line to your ~/.bashrc file:`]; - - if (customDir) { - instructions.push( - ` export SAFE_CHAIN_DIR="${customDir}"`, - ` source ${path.join(getScriptsDir(), "init-posix.sh")}`, - ); - } else { - instructions.push(` source ~/.safe-chain/scripts/init-posix.sh`); - } - - instructions.push(`Then restart your terminal or run: source ~/.bashrc`); - return instructions; + return buildManualInstructions(`Add the following line to your ~/.bashrc file:`); } /** diff --git a/packages/safe-chain/src/shell-integration/supported-shells/fish.js b/packages/safe-chain/src/shell-integration/supported-shells/fish.js index 33aa48c..a6ffe1e 100644 --- a/packages/safe-chain/src/shell-integration/supported-shells/fish.js +++ b/packages/safe-chain/src/shell-integration/supported-shells/fish.js @@ -84,11 +84,10 @@ function getStartupFile() { } } -function getManualTeardownInstructions() { +/** @param {string} preamble */ +function buildManualInstructions(preamble) { const customDir = getSafeChainDir(); - const instructions = [ - `Remove the following line from your ~/.config/fish/config.fish file:`, - ]; + const instructions = [preamble]; if (customDir) { instructions.push( @@ -105,25 +104,12 @@ function getManualTeardownInstructions() { return instructions; } +function getManualTeardownInstructions() { + return buildManualInstructions(`Remove the following line from your ~/.config/fish/config.fish file:`); +} + function getManualSetupInstructions() { - const customDir = getSafeChainDir(); - const instructions = [ - `Add the following line to your ~/.config/fish/config.fish file:`, - ]; - - if (customDir) { - instructions.push( - ` set -gx SAFE_CHAIN_DIR "${customDir}"`, - ` source ${path.join(getScriptsDir(), "init-fish.fish")}`, - ); - } else { - instructions.push(` source ~/.safe-chain/scripts/init-fish.fish`); - } - - instructions.push( - `Then restart your terminal or run: source ~/.config/fish/config.fish`, - ); - return instructions; + return buildManualInstructions(`Add the following line to your ~/.config/fish/config.fish file:`); } /** diff --git a/packages/safe-chain/src/shell-integration/supported-shells/powershell.js b/packages/safe-chain/src/shell-integration/supported-shells/powershell.js index 44fbfe9..906bedd 100644 --- a/packages/safe-chain/src/shell-integration/supported-shells/powershell.js +++ b/packages/safe-chain/src/shell-integration/supported-shells/powershell.js @@ -87,11 +87,10 @@ function getStartupFile() { } } -function getManualTeardownInstructions() { +/** @param {string} preamble */ +function buildManualInstructions(preamble) { const customDir = getSafeChainDir(); - const instructions = [ - `Remove the following line from your PowerShell profile (run "echo $PROFILE" to find its location):`, - ]; + const instructions = [preamble]; if (customDir) { instructions.push( @@ -106,23 +105,12 @@ function getManualTeardownInstructions() { return instructions; } +function getManualTeardownInstructions() { + return buildManualInstructions(`Remove the following line from your PowerShell profile (run "echo $PROFILE" to find its location):`); +} + function getManualSetupInstructions() { - const customDir = getSafeChainDir(); - const instructions = [ - `Add the following line to your PowerShell profile (run "echo $PROFILE" to find its location):`, - ]; - - if (customDir) { - instructions.push( - ` $env:SAFE_CHAIN_DIR = '${customDir}'`, - ` . "${path.join(getScriptsDir(), "init-pwsh.ps1")}"`, - ); - } else { - instructions.push(` . "$HOME\\.safe-chain\\scripts\\init-pwsh.ps1"`); - } - - instructions.push(`Then restart your terminal or run: . $PROFILE`); - return instructions; + return buildManualInstructions(`Add the following line to your PowerShell profile (run "echo $PROFILE" to find its location):`); } /** diff --git a/packages/safe-chain/src/shell-integration/supported-shells/windowsPowershell.js b/packages/safe-chain/src/shell-integration/supported-shells/windowsPowershell.js index 041cca7..e53891e 100644 --- a/packages/safe-chain/src/shell-integration/supported-shells/windowsPowershell.js +++ b/packages/safe-chain/src/shell-integration/supported-shells/windowsPowershell.js @@ -87,11 +87,10 @@ function getStartupFile() { } } -function getManualTeardownInstructions() { +/** @param {string} preamble */ +function buildManualInstructions(preamble) { const customDir = getSafeChainDir(); - const instructions = [ - `Remove the following line from your PowerShell profile (run "echo $PROFILE" to find its location):`, - ]; + const instructions = [preamble]; if (customDir) { instructions.push( @@ -106,23 +105,12 @@ function getManualTeardownInstructions() { return instructions; } +function getManualTeardownInstructions() { + return buildManualInstructions(`Remove the following line from your PowerShell profile (run "echo $PROFILE" to find its location):`); +} + function getManualSetupInstructions() { - const customDir = getSafeChainDir(); - const instructions = [ - `Add the following line to your PowerShell profile (run "echo $PROFILE" to find its location):`, - ]; - - if (customDir) { - instructions.push( - ` $env:SAFE_CHAIN_DIR = '${customDir}'`, - ` . "${path.join(getScriptsDir(), "init-pwsh.ps1")}"`, - ); - } else { - instructions.push(` . "$HOME\\.safe-chain\\scripts\\init-pwsh.ps1"`); - } - - instructions.push(`Then restart your terminal or run: . $PROFILE`); - return instructions; + return buildManualInstructions(`Add the following line to your PowerShell profile (run "echo $PROFILE" to find its location):`); } /** diff --git a/packages/safe-chain/src/shell-integration/supported-shells/zsh.js b/packages/safe-chain/src/shell-integration/supported-shells/zsh.js index c9be67f..9b87d86 100644 --- a/packages/safe-chain/src/shell-integration/supported-shells/zsh.js +++ b/packages/safe-chain/src/shell-integration/supported-shells/zsh.js @@ -84,9 +84,10 @@ function getStartupFile() { } } -function getManualTeardownInstructions() { +/** @param {string} preamble */ +function buildManualInstructions(preamble) { const customDir = getSafeChainDir(); - const instructions = [`Remove the following line from your ~/.zshrc file:`]; + const instructions = [preamble]; if (customDir) { instructions.push( @@ -101,21 +102,12 @@ function getManualTeardownInstructions() { return instructions; } +function getManualTeardownInstructions() { + return buildManualInstructions(`Remove the following line from your ~/.zshrc file:`); +} + function getManualSetupInstructions() { - const customDir = getSafeChainDir(); - const instructions = [`Add the following line to your ~/.zshrc file:`]; - - if (customDir) { - instructions.push( - ` export SAFE_CHAIN_DIR="${customDir}"`, - ` source ${path.join(getScriptsDir(), "init-posix.sh")}`, - ); - } else { - instructions.push(` source ~/.safe-chain/scripts/init-posix.sh`); - } - - instructions.push(`Then restart your terminal or run: source ~/.zshrc`); - return instructions; + return buildManualInstructions(`Add the following line to your ~/.zshrc file:`); } export default {