Skip to content

Commit

Permalink
fix: forgot sourceLineForShell
Browse files Browse the repository at this point in the history
  • Loading branch information
KSXGitHub committed Feb 1, 2024
1 parent b939bb6 commit 07b8754
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions lib/installer.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,9 @@ const locationFromShell = shell => {
* If the provided SHELL is not known, it returns the source line for a Bash shell.
*
* @param {String} scriptname - The script to source
* @param {String} shell - Shell to base the check on, defaults to system
* shell.
* @param {SupportedShell} shell - Shell to base the check on
*/
const sourceLineForShell = (scriptname, shell = systemShell()) => {
const sourceLineForShell = (scriptname, shell) => {
if (shell === 'fish') {
return `[ -f ${scriptname} ]; and . ${scriptname}; or true`;
}
Expand All @@ -73,8 +72,11 @@ const sourceLineForShell = (scriptname, shell = systemShell()) => {
return `if (Test-Path ${scriptname}) { . ${scriptname} }`;
}

// For Bash and others
return `[ -f ${scriptname} ] && . ${scriptname} || true`;
if (shell === 'bash') {
return `[ -f ${scriptname} ] && . ${scriptname} || true`;
}

throw new Error(`Unsupported shell: ${shell}`);
};

/**
Expand Down Expand Up @@ -131,7 +133,7 @@ const checkFilenameForLine = async (filename, line) => {
* @param {String} options.filename - The file to modify.
* @param {String} options.scriptname - The line to add sourcing this file.
* @param {String} options.name - The package being configured.
* @param {String} options.shell
* @param {SupportedShell} options.shell
* @returns {Promise.<void>}
*/
const writeLineToFilename = ({ filename, scriptname, name, shell }) => new Promise((
Expand Down

0 comments on commit 07b8754

Please sign in to comment.