mirror of
https://github.com/scratchfoundation/scratch-l10n.git
synced 2024-11-14 19:35:10 -05:00
fix: stop trying to assign an array to process.exitCode
This commit is contained in:
parent
9001b61085
commit
a4b16805f4
1 changed files with 20 additions and 17 deletions
|
@ -72,22 +72,27 @@ const txPushResource = async (name, articles, type) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get a flattened list of folders
|
* get a flattened list of folders associated with the specified categories
|
||||||
* @param {category} categories array of categories the folders belong to
|
* @param {object[]} categories array of categories the folders belong to
|
||||||
* @return {Promise} flattened list of folders
|
* @return {Promise<object[]>} flattened list of folders from all requested categories
|
||||||
*/
|
*/
|
||||||
const getFolders = async (categories) => {
|
const getFolders = async (categories) => {
|
||||||
let categoryFolders = await Promise.all( // eslint-disable-line no-undef
|
const categoryFolders = await Promise.all(
|
||||||
categories.map(category => FD.listFolders(category))
|
categories.map(category => FD.listFolders(category))
|
||||||
);
|
);
|
||||||
return [].concat(...categoryFolders);
|
return [].concat(...categoryFolders);
|
||||||
};
|
};
|
||||||
|
|
||||||
const PUBLISHED = 2; // in Freshdesk, draft status = 1, and published = 2
|
const PUBLISHED = 2; // in Freshdesk, draft status = 1, and published = 2
|
||||||
const saveArticles = (folder) => {
|
|
||||||
FD.listArticles(folder)
|
/**
|
||||||
|
* Save articles in a particular folder
|
||||||
|
* @param {object} folder The folder object
|
||||||
|
*/
|
||||||
|
const saveArticles = async folder => {
|
||||||
|
await FD.listArticles(folder)
|
||||||
.then(json => {
|
.then(json => {
|
||||||
let txArticles = json.reduce((strings, current) => {
|
const txArticles = json.reduce((strings, current) => {
|
||||||
if (current.status === PUBLISHED) {
|
if (current.status === PUBLISHED) {
|
||||||
strings[`${current.id}`] = {
|
strings[`${current.id}`] = {
|
||||||
title: {
|
title: {
|
||||||
|
@ -107,13 +112,16 @@ const saveArticles = (folder) => {
|
||||||
txPushResource(`${makeTxId(folder)}_json`, txArticles, 'STRUCTURED_JSON');
|
txPushResource(`${makeTxId(folder)}_json`, txArticles, 'STRUCTURED_JSON');
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
const getArticles = async (folders) => {
|
|
||||||
return Promise.all(folders.map(folder => saveArticles(folder))); // eslint-disable-line no-undef
|
/**
|
||||||
|
* @param {object[]} folders Array of folders containing articles to be saved
|
||||||
|
*/
|
||||||
|
const saveArticleFolders = async (folders) => {
|
||||||
|
await Promise.all(folders.map(folder => saveArticles(folder)));
|
||||||
};
|
};
|
||||||
|
|
||||||
const syncSources = async () => {
|
const syncSources = async () => {
|
||||||
let status = 0;
|
await FD.listCategories()
|
||||||
status = await FD.listCategories()
|
|
||||||
.then(json => {
|
.then(json => {
|
||||||
// save category names for translation
|
// save category names for translation
|
||||||
for (let cat of json.values()) {
|
for (let cat of json.values()) {
|
||||||
|
@ -131,12 +139,7 @@ const syncSources = async () => {
|
||||||
txPushResource('folderNames_json', folderNames, 'KEYVALUEJSON');
|
txPushResource('folderNames_json', folderNames, 'KEYVALUEJSON');
|
||||||
return data;
|
return data;
|
||||||
})
|
})
|
||||||
.then(getArticles)
|
.then(saveArticleFolders);
|
||||||
.catch((e) => {
|
|
||||||
process.stdout.write(`Error:${e.message}\n`);
|
|
||||||
return 1;
|
|
||||||
});
|
|
||||||
process.exitCode = status;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
syncSources();
|
syncSources();
|
||||||
|
|
Loading…
Reference in a new issue