Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ Add a `.gitporc` with the followings:
{
"API_TOKEN": "<your POEditor API key>",
"HOOKS": {
"<projectId>": {
"<projectId>": [{
"IMPORT": "<webhook_url>",
"SYNC": "<webhook_url>",
"EXPORT": {
"fr": "<webhook_url>",
"en": "<webhook_url>"
}
}
}]
}
}
```
Expand Down
16 changes: 9 additions & 7 deletions config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
module.exports = require('rc')('gitpo', {
API_TOKEN: '<your POEditor API key>',
HOOKS: {
'<projectId>': {
IMPORT: '<webhook_url>', // only one language needed as we import TERMS only
SYNC: '<webhook_url>', // only one language needed as we import TERMS only
EXPORT: {
fr: '<webhook_url>',
en: '<webhook_url>',
'<projectId>': [
{
IMPORT: '<webhook_url>', // only one language needed as we import TERMS only
SYNC: '<webhook_url>', // only one language needed as we import TERMS only
EXPORT: {
fr: '<webhook_url>',
en: '<webhook_url>',
},
},
},
],
},
})
3 changes: 2 additions & 1 deletion lib/webhooks/importNewTerms.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const rp = require('request-promise')

module.exports = ({ HOOKS }) => async (projectId) => rp({ method: 'GET', url: HOOKS[projectId].IMPORT })
module.exports = ({ HOOKS }) => async (projectId) =>
Promise.all(HOOKS[projectId].map(({ IMPORT }) => rp({ method: 'GET', url: IMPORT })))
3 changes: 2 additions & 1 deletion lib/webhooks/synchronizeTerms.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const rp = require('request-promise')

module.exports = ({ HOOKS }) => async (projectId) => rp({ method: 'GET', url: HOOKS[projectId].SYNC })
module.exports = ({ HOOKS }) => async (projectId) =>
Promise.all(HOOKS[projectId].map(({ SYNC }) => rp({ method: 'GET', url: SYNC })))
7 changes: 6 additions & 1 deletion lib/webhooks/updateTranslations.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
const rp = require('request-promise')

module.exports = ({ HOOKS }) => async (projectId, languages) =>
Promise.all(languages.map((lng) => rp({ method: 'GET', url: HOOKS[projectId].EXPORT[lng] })))
Promise.all(
HOOKS[projectId].reduce(
(acc, { EXPORT }) => [...acc, ...languages.map((lng) => rp({ method: 'GET', url: EXPORT[lng] }))],
[],
),
)