File tree Expand file tree Collapse file tree 3 files changed +21
-3
lines changed Expand file tree Collapse file tree 3 files changed +21
-3
lines changed Original file line number Diff line number Diff line change 46
46
},
47
47
"dependencies" : {
48
48
"chalk" : " ^2.4.1" ,
49
+ "delay" : " ^4.3.0" ,
49
50
"execa" : " ^1.0.0" ,
50
51
"got" : " ^9.6.0" ,
51
52
"inquirer" : " ^6.3.1" ,
Original file line number Diff line number Diff line change
1
+ import delay from 'delay'
1
2
import got , { GotInstance , GotJSONFn } from 'got'
2
3
import * as yaml from 'js-yaml'
3
4
import { exists } from 'mz/fs'
@@ -114,11 +115,22 @@ export async function initTravis({
114
115
await travisClient . post ( `user/${ travisUser . id } /sync` )
115
116
while ( ( await getCurrentTravisUser ( { travisClient } ) ) . is_syncing ) {
116
117
console . log ( 'Waiting for sync to finish...' )
117
- await new Promise < void > ( resolve => setTimeout ( resolve , 1000 ) )
118
+ await delay ( 1000 )
118
119
}
119
120
120
- console . log ( `Activating repository at https://travis-ci.org/sourcegraph/${ repoName } ` )
121
- await travisClient . post ( `/repo/sourcegraph%2F${ repoName } /activate` )
121
+ // Retry activating while repository is not found (404)
122
+ while ( true ) {
123
+ try {
124
+ await delay ( 1000 )
125
+ console . log ( `Activating repository at https://travis-ci.org/sourcegraph/${ repoName } ` )
126
+ await travisClient . post ( `/repo/sourcegraph%2F${ repoName } /activate` )
127
+ break
128
+ } catch ( err ) {
129
+ if ( err . status !== 404 ) {
130
+ throw err
131
+ }
132
+ }
133
+ }
122
134
123
135
const envVars = ( await travisClient . get ( `/repo/sourcegraph%2F${ repoName } /env_vars` ) ) . body
124
136
if ( envVars . env_vars . some ( ( envVar : any ) => envVar . name === 'NPM_TOKEN' ) ) {
Original file line number Diff line number Diff line change @@ -1563,6 +1563,11 @@ define-property@^2.0.2:
1563
1563
is-descriptor "^1.0.2"
1564
1564
isobject "^3.0.1"
1565
1565
1566
+ delay@^4.3.0 :
1567
+ version "4.3.0"
1568
+ resolved "https://registry.npmjs.org/delay/-/delay-4.3.0.tgz#efeebfb8f545579cb396b3a722443ec96d14c50e"
1569
+ integrity sha512-Lwaf3zVFDMBop1yDuFZ19F9WyGcZcGacsbdlZtWjQmM50tOcMntm1njF/Nb/Vjij3KaSvCF+sEYGKrrjObu2NA==
1570
+
1566
1571
delayed-stream@~1.0.0 :
1567
1572
version "1.0.0"
1568
1573
resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619"
You can’t perform that action at this time.
0 commit comments