This repository was archived by the owner on Jul 6, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +16
-9
lines changed Expand file tree Collapse file tree 2 files changed +16
-9
lines changed Original file line number Diff line number Diff line change @@ -26,21 +26,23 @@ function __fish_command_not_found_on_interactive --on-event fish_prompt
26
26
functions --erase __fish_command_not_found_on_interactive
27
27
end`
28
28
29
- module . exports = function autoFallback ( shell ) {
30
- const SHELL = process . env . SHELL || ''
31
-
32
- if ( shell === 'bash' || SHELL . includes ( 'bash' ) ) {
29
+ module . exports = autoFallback
30
+ function autoFallback ( shell , fromEnv ) {
31
+ if ( shell . includes ( 'bash' ) ) {
33
32
return POSIX . replace ( 'handler()' , 'handle()' )
34
33
}
35
34
36
- if ( shell === 'zsh' || SHELL . includes ( 'zsh' ) ) {
35
+ if ( shell . includes ( 'zsh' ) ) {
37
36
return POSIX
38
37
}
39
38
40
- if ( shell === 'fish' || SHELL . includes ( 'fish' ) ) {
39
+ if ( shell . includes ( 'fish' ) ) {
41
40
return FISH
42
41
}
43
42
43
+ if ( fromEnv ) {
44
+ return autoFallback ( fromEnv )
45
+ }
46
+
44
47
console . error ( 'Only Bash, Zsh, and Fish shells are supported :(' )
45
- process . exit ( 1 )
46
48
}
Original file line number Diff line number Diff line change @@ -21,8 +21,13 @@ main(parseArgs())
21
21
function main ( argv ) {
22
22
const shell = argv [ 'shell-auto-fallback' ]
23
23
if ( shell || shell === '' ) {
24
- console . log ( autoFallback ( shell ) )
25
- process . exit ( 0 )
24
+ const fallback = autoFallback ( shell , process . env . SHELL )
25
+ if ( fallback ) {
26
+ console . log ( fallback )
27
+ process . exit ( 0 )
28
+ } else {
29
+ process . exit ( 1 )
30
+ }
26
31
}
27
32
28
33
if ( ! argv . command || ! argv . package ) {
You can’t perform that action at this time.
0 commit comments