Skip to content

Commit

Permalink
fix l10n script
Browse files Browse the repository at this point in the history
  • Loading branch information
jchip committed Mar 5, 2021
1 parent e96f8d7 commit 7728699
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/xarc-app-dev/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
"webpack-dev-middleware": "^3.7.2",
"webpack-hot-middleware": "^2.25.0",
"winston": "^2.4.4",
"xaa": "^1.6.2",
"xaa": "^1.7.0",
"xenv-config": "^1.3.1",
"xsh": "^0.4.5"
},
Expand Down
18 changes: 9 additions & 9 deletions packages/xarc-app-dev/scripts/l10n/flatten-messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const getFilePaths = Util.promisify(require("glob"));
const MESSAGES_PATTERN = "./tmp/messages/**/*.json";
const RAW_MESSAGES_DIR = "./dist/";
const RAW_MESSAGES_NAME = "raw-messages.json";
const xaa = require("xaa");

/**
* @param {String} filePath The file path
Expand Down Expand Up @@ -37,15 +38,14 @@ function readFileAsJSON(filePath) {
* @return {Promise} A promise that resolves to a flat POJO with the default messages extracted
* from all files
*/
function getAllDefaultMessages(messageFilesPathPattern) {
return getFilePaths(messageFilesPathPattern)
.map(readFileAsJSON)
.reduce((previousValue, defaultMessageDescriptors) => {
defaultMessageDescriptors.forEach(descriptor => {
previousValue[descriptor.id] = descriptor;
});
return previousValue;
}, {});
async function getAllDefaultMessages(messageFilesPathPattern) {
const fileJsons = await xaa.map(await getFilePaths(messageFilesPathPattern), readFileAsJSON);
return fileJsons.reduce((previousValue, defaultMessageDescriptors) => {
defaultMessageDescriptors.forEach(descriptor => {
previousValue[descriptor.id] = descriptor;
});
return previousValue;
}, {});
}

const writeRawMessages = _.partial(writeFileAsJSON, RAW_MESSAGES_DIR, RAW_MESSAGES_NAME);
Expand Down

0 comments on commit 7728699

Please sign in to comment.