File tree Expand file tree Collapse file tree 2 files changed +21
-5
lines changed Expand file tree Collapse file tree 2 files changed +21
-5
lines changed Original file line number Diff line number Diff line change @@ -4,11 +4,17 @@ const path = require('path')
44
55async function getCrowdinFileIds ( project , crowdinKey ) {
66 crowdinKey = crowdinKey || process . env . CROWDIN_KEY
7+ let url
78
89 assert ( project , '`project` must be the first argument' )
9- assert ( crowdinKey , '`crowdinKey` must be the second argument or process.env.CROWDIN_KEY' )
1010
11- const url = `https://api.crowdin.com/api/project/${ project } /info?key=${ crowdinKey } &json`
11+ if ( project === 'electron' ) {
12+ url = 'https://electronjs.org/crowdin/info'
13+ } else {
14+ assert ( crowdinKey , '`crowdinKey` must be the second argument or process.env.CROWDIN_KEY' )
15+ url = `https://api.crowdin.com/api/project/${ project } /info?key=${ crowdinKey } &json`
16+ }
17+
1218 const res = await post ( url , { json : true } )
1319 return resolveFile ( { } , res . body . files )
1420}
Original file line number Diff line number Diff line change @@ -15,11 +15,11 @@ describe('getCrowdinFileIds', () => {
1515 } )
1616
1717 it ( 'expects project name and Crowdin API key as arguments' , async ( ) => {
18- crowdin . post ( '/project/electron /info?key=xyz&json' )
18+ crowdin . post ( '/project/foo-project /info?key=xyz&json' )
1919 . once ( )
2020 . reply ( 200 , require ( './fixture.json' ) )
2121
22- const urls = await getCrowdinFileIds ( 'electron ' , 'xyz' )
22+ const urls = await getCrowdinFileIds ( 'foo-project ' , 'xyz' )
2323 const paths = Object . keys ( urls )
2424
2525 urls . should . be . an ( 'object' )
@@ -30,7 +30,17 @@ describe('getCrowdinFileIds', () => {
3030 } )
3131
3232 it ( 'falls back to CROWDIN_KEY env var' , async ( ) => {
33- crowdin . post ( '/project/electron/info?key=abc&json' )
33+ crowdin . post ( '/project/bar-project/info?key=abc&json' )
34+ . once ( )
35+ . reply ( 200 , require ( './fixture.json' ) )
36+
37+ const urls = await getCrowdinFileIds ( 'bar-project' )
38+ urls . should . be . an ( 'object' )
39+ } )
40+
41+ it ( 'uses the unauthenticated website proxy for the `electron` project' , async ( ) => {
42+ nock ( 'https://electronjs.org/crowdin' )
43+ . post ( '/info' )
3444 . once ( )
3545 . reply ( 200 , require ( './fixture.json' ) )
3646
You can’t perform that action at this time.
0 commit comments