continue instead of returning in loop. move out build command
This commit is contained in:
parent
201a498631
commit
207752e873
4 changed files with 10 additions and 7 deletions
|
@ -31,7 +31,7 @@ core:
|
||||||
testonly: 'npx mocha tests/*.test.js'
|
testonly: 'npx mocha tests/*.test.js'
|
||||||
i18n:
|
i18n:
|
||||||
# react-scripts doesn't handle .mjs files correctly
|
# react-scripts doesn't handle .mjs files correctly
|
||||||
prebuild: 'node src/prebuild.mjs'
|
prebuild: 'node scripts/prebuilder.mjs'
|
||||||
test: *test
|
test: *test
|
||||||
testci: *testci
|
testci: *testci
|
||||||
new-design:
|
new-design:
|
||||||
|
|
|
@ -31,9 +31,9 @@
|
||||||
"vbuild": "VERBOSE=1 node build.js",
|
"vbuild": "VERBOSE=1 node build.js",
|
||||||
"lab": "cd ../../sites/lab && yarn start",
|
"lab": "cd ../../sites/lab && yarn start",
|
||||||
"tips": "node ../../scripts/help.mjs",
|
"tips": "node ../../scripts/help.mjs",
|
||||||
"prebuild": "node src/prebuild.mjs",
|
"prebuild": "node scripts/prebuilder.mjs",
|
||||||
"testci": "npx mocha tests/*.test.mjs --reporter ../../tests/reporters/terse.js",
|
"testci": "npx mocha tests/*.test.mjs --reporter ../../tests/reporters/terse.js",
|
||||||
"precibuild_step7": "node src/prebuild.mjs",
|
"precibuild_step7": "node scripts/prebuilder.mjs",
|
||||||
"cibuild_step7": "node build.js"
|
"cibuild_step7": "node build.js"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
|
|
4
packages/i18n/scripts/prebuilder.mjs
Normal file
4
packages/i18n/scripts/prebuilder.mjs
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
import {build} from '../src/prebuild.mjs'
|
||||||
|
|
||||||
|
// call this here instead of in the src/prebuild.mjs so that build isn't called by other files importing that build function
|
||||||
|
build()
|
|
@ -108,10 +108,10 @@ const getNamespacesFromFileList = async (files, locales, only=false) => {
|
||||||
let file = files[i]
|
let file = files[i]
|
||||||
|
|
||||||
let loc = localeFromFileName(file);
|
let loc = localeFromFileName(file);
|
||||||
if (locales.indexOf(loc) === -1) return
|
if (locales.indexOf(loc) === -1) continue
|
||||||
|
|
||||||
let namespace = namespaceFromFile(file);
|
let namespace = namespaceFromFile(file);
|
||||||
if (only === true && only.indexOf(namespace) === -1) return
|
if (only === true && only.indexOf(namespace) === -1) continue
|
||||||
|
|
||||||
if (typeof namespaces[loc] === 'undefined') {
|
if (typeof namespaces[loc] === 'undefined') {
|
||||||
namespaces[loc] = {}
|
namespaces[loc] = {}
|
||||||
|
@ -216,12 +216,11 @@ const writeFiles = async allNamespaces => {
|
||||||
export const build = async (localeFilter = () => true, only=false) => {
|
export const build = async (localeFilter = () => true, only=false) => {
|
||||||
const files = await getTranslationFileList()
|
const files = await getTranslationFileList()
|
||||||
const locales = getLocalesFromFileList(files).filter(localeFilter)
|
const locales = getLocalesFromFileList(files).filter(localeFilter)
|
||||||
|
console.log('building i18n for', locales)
|
||||||
const namespaces = await getNamespacesFromFileList(files, locales, only)
|
const namespaces = await getNamespacesFromFileList(files, locales, only)
|
||||||
|
|
||||||
await writeFiles(namespaces)
|
await writeFiles(namespaces)
|
||||||
}
|
}
|
||||||
|
|
||||||
build()
|
|
||||||
|
|
||||||
//export default strings
|
//export default strings
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue