File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,14 @@ $ git stash -u
36
36
$ git stash pop
37
37
` ;
38
38
39
+ const FETCH_TIMEOUT = 10 * 1000 ; // 10 seconds
40
+
41
+ function timeoutPromise ( millis ) {
42
+ return new Promise ( ( resolve , reject ) => {
43
+ setTimeout ( reject , millis ) ;
44
+ } ) ;
45
+ }
46
+
39
47
( async ( ) => {
40
48
try {
41
49
const hasDiff = ! ! ( await git . diff ( ) ) ;
@@ -50,7 +58,10 @@ $ git stash pop
50
58
' Fetching latest version of master branch.'
51
59
) . start ( ) ;
52
60
try {
53
- await git . fetch ( 'origin' , 'master' ) ;
61
+ await Promise . race ( [
62
+ git . fetch ( 'origin' , 'master' ) ,
63
+ timeoutPromise ( FETCH_TIMEOUT )
64
+ ] ) ;
54
65
fetchSpinner . stopAndPersist ( {
55
66
symbol : '✅'
56
67
} ) ;
@@ -59,7 +70,7 @@ $ git stash pop
59
70
symbol : '⚠️'
60
71
} ) ;
61
72
console . warn (
62
- chalk `\n{yellow} Unable to fetch latest version of master, diff may be stale.`
73
+ chalk `\n{yellow WARNING: Unable to fetch latest version of master, diff may be stale.} `
63
74
) ;
64
75
}
65
76
You can’t perform that action at this time.
0 commit comments