Skip to content

Commit

Permalink
maintenance (scripts/i18n) Create run-all i18n script (#22873)
Browse files Browse the repository at this point in the history
* Create run-all i18n script

* error checking

* add more documentation
  • Loading branch information
tesseralis committed Apr 9, 2020
1 parent d6ac255 commit f0ec0b5
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
10 changes: 10 additions & 0 deletions scripts/i18n/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,13 @@ When run, the script will:
- Pulls the latest version of `gatsby-i18n-source`.
- Creates a "sync" pull request that updates all files that do not contain conflicts from the merge.
- Creates a "conflicts" pull request that contains all merge conflicts, with instructions on how to resolve them.
### `run-all`
Usage:
```shell
yarn run-all [script name]
```
The `run-all` script runs the script provided in the argument across all languages for which there are translations of gatbyjs.org, listed in /www/src/i18n.json.
1 change: 1 addition & 0 deletions scripts/i18n/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"description": "Scripts for gatsby internationalization",
"scripts": {
"create": "node ./create.js",
"run-all": "node ./run-all.js",
"sync": "node ./sync.js",
"update-source": "node ./update-source.js"
},
Expand Down
21 changes: 21 additions & 0 deletions scripts/i18n/run-all.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Run the provided script on all valid repos
const fs = require(`fs`)
const log4js = require(`log4js`)
const shell = require(`shelljs`)
let logger = log4js.getLogger(`run-all`)

require(`dotenv`).config()

function runAll(script) {
if (!script) {
logger.error(`Usage: yarn run-all <script-name>`)
process.exit(1)
}
const langs = JSON.parse(fs.readFileSync(`../../www/i18n.json`))
for (const { code } of langs) {
shell.exec(`yarn ${script} ${code}`)
}
}

const [script] = process.argv.slice(2)
runAll(script)

0 comments on commit f0ec0b5

Please sign in to comment.