@@ -134,33 +134,29 @@ const setupWindowsPath = async function () {
134134 )
135135}
136136
137- const getInitContent = ( incFilePath ) => `
137+ const CONTENT_COMMENT = `
138138# The next line updates PATH for Netlify's Git Credential Helper.
139- if [ -f '${ incFilePath } ' ]; then source '${ incFilePath } '; fi
140139`
141140
141+ const getInitContent = ( incFilePath ) => `${ CONTENT_COMMENT } test -f '${ incFilePath } ' && source '${ incFilePath } '`
142+
142143const setupUnixPath = async ( ) => {
143144 if ( isBinInPath ( ) ) {
144145 return true
145146 }
146147
147- const { shell, incFilePath, configFile } = shellVariables ( )
148- const initContent = getInitContent ( incFilePath )
148+ const { shell, incFilePath, configFile } = getShellInfo ( )
149149
150- switch ( shell ) {
151- case 'bash' :
152- case 'zsh' : {
153- return await Promise . all ( [
154- await copyFileAsync ( `${ __dirname } /scripts/${ shell } .sh` , incFilePath ) ,
155- await writeConfig ( configFile , initContent ) ,
156- ] )
157- }
158- default : {
159- const error = `Unable to set credential helper in PATH. We don't how to set the path for ${ shell } shell.
150+ if ( configFile === undefined ) {
151+ const error = `Unable to set credential helper in PATH. We don't how to set the path for ${ shell } shell.
160152Set the helper path in your environment PATH: ${ getBinPath ( ) } `
161- throw new Error ( error )
162- }
153+ throw new Error ( error )
163154 }
155+
156+ return await Promise . all ( [
157+ await copyFileAsync ( `${ __dirname } /scripts/${ shell } .sh` , incFilePath ) ,
158+ await writeConfig ( configFile , getInitContent ( incFilePath ) ) ,
159+ ] )
164160}
165161
166162const writeConfig = async function ( name , initContent ) {
@@ -253,9 +249,10 @@ const getLegacyBinPath = function () {
253249const CONFIG_FILES = {
254250 bash : '.bashrc' ,
255251 zsh : '.zshrc' ,
252+ fish : '.config/fish/config.fish' ,
256253}
257254
258- const shellVariables = function ( ) {
255+ const getShellInfo = function ( ) {
259256 const shellEnv = process . env . SHELL
260257 if ( ! shellEnv ) {
261258 throw new Error ( 'Unable to detect SHELL type, make sure the variable is defined in your environment' )
@@ -271,7 +268,7 @@ const shellVariables = function () {
271268
272269const cleanupShell = async function ( ) {
273270 try {
274- const { configFile, incFilePath } = shellVariables ( )
271+ const { configFile, incFilePath } = getShellInfo ( )
275272 if ( configFile === undefined ) {
276273 return
277274 }
@@ -299,4 +296,4 @@ const removeConfig = async function (name, toRemove) {
299296 return await writeFileAsync ( configPath , content . replace ( toRemove , '' ) )
300297}
301298
302- module . exports = { installPlatform, isBinInPath, shellVariables , uninstall }
299+ module . exports = { installPlatform, isBinInPath, getShellInfo , uninstall }
0 commit comments