@@ -20,37 +20,38 @@ const makeDir = require('make-dir')
20
20
* respective profiles updated with the source command.
21
21
*/
22
22
class Profile {
23
- constructor ( { env, runlog } ) {
23
+ constructor ( { env, runlog, pathChecks } ) {
24
24
this . env = env
25
+ this . pathChecks = pathChecks
25
26
this . runlog = runlog
26
27
// shells and an appropriate config file to add our source line to
27
28
// ref: https://en.wikipedia.org/wiki/Unix_shell#Configuration_files
28
29
this . SUPPORTED_SHELLS = {
29
30
shellFormat : {
30
31
// only support shells that support functions
31
32
// ref: https://web.archive.org/web/20160403120601/http://www.unixnote.com/2010/05/different-unix-shell.html
32
- sh : [ this . inHome ( '.profile' ) ] ,
33
- ksh : [ this . inHome ( '.kshrc' ) ] ,
34
- zsh : [ this . inHome ( '.zshrc' ) , this . inHome ( '.profile' ) , this . inHome ( '.zprofile' ) ] ,
35
- bash : [ this . inHome ( '.bashrc' ) , this . inHome ( '.profile' ) , this . inHome ( '.bash_profile' ) ]
33
+ sh : [ this . pathChecks . inHome ( '.profile' ) ] ,
34
+ ksh : [ this . pathChecks . inHome ( '.kshrc' ) ] ,
35
+ zsh : [
36
+ this . pathChecks . inHome ( '.zshrc' ) ,
37
+ this . pathChecks . inHome ( '.profile' ) ,
38
+ this . pathChecks . inHome ( '.zprofile' )
39
+ ] ,
40
+ bash : [
41
+ this . pathChecks . inHome ( '.bashrc' ) ,
42
+ this . pathChecks . inHome ( '.profile' ) ,
43
+ this . pathChecks . inHome ( '.bash_profile' )
44
+ ]
36
45
} ,
37
46
powerFormat : {
38
47
pwsh : os . platform ( ) !== 'win32' // pwsh stores its profile in different places depending on the OS
39
- ? [ this . inConfig ( 'powershell' , 'Microsoft.PowerShell_profile.ps1' ) ]
40
- : [ this . inHome ( 'Documents' , 'PowerShell' , 'Microsoft.PowerShell_profile.ps1' ) ] ,
41
- 'powershell.exe' : [ this . inHome ( 'Documents' , 'WindowsPowerShell' , 'Microsoft.PowerShell_profile.ps1' ) ]
48
+ ? [ this . pathChecks . inConfig ( 'powershell' , 'Microsoft.PowerShell_profile.ps1' ) ]
49
+ : [ this . pathChecks . inHome ( 'Documents' , 'PowerShell' , 'Microsoft.PowerShell_profile.ps1' ) ] ,
50
+ 'powershell.exe' : [ this . pathChecks . inHome ( 'Documents' , 'WindowsPowerShell' , 'Microsoft.PowerShell_profile.ps1' ) ]
42
51
}
43
52
}
44
53
}
45
54
46
- inHome ( ...filepaths ) {
47
- return path . join ( os . homedir ( ) , ...filepaths )
48
- }
49
-
50
- inConfig ( ...filepaths ) {
51
- return this . inHome ( '.config' , ...filepaths )
52
- }
53
-
54
55
async installToProfiles ( ) {
55
56
return this . _updateProfiles ( { install : true } )
56
57
}
0 commit comments