From 7bd45e7adacc2330400e86f0bbff40b347c841b7 Mon Sep 17 00:00:00 2001 From: ErickSkrauch Date: Mon, 15 Jun 2020 00:22:19 +0300 Subject: [PATCH] Improve file search algorithm --- config.js | 4 +--- packages/scripts/i18n-crowdin.ts | 15 +++++++++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/config.js b/config.js index e6b90a2..ff7ed81 100644 --- a/config.js +++ b/config.js @@ -1,8 +1,6 @@ /* eslint-env node */ /* eslint-disable @typescript-eslint/no-var-requires */ -const path = require('path'); - require('dotenv').config(); const { env } = process; @@ -17,7 +15,7 @@ module.exports = { projectId: 350687, filePath: 'accounts/site.json', sourceLang: 'en', - basePath: path.resolve(`${__dirname}/packages/app/i18n`), + basePath: `${__dirname}/packages/app/i18n`, minApproved: 80, // Minimal ready percent before translation can be published }, }; diff --git a/packages/scripts/i18n-crowdin.ts b/packages/scripts/i18n-crowdin.ts index 4e3af22..341f170 100644 --- a/packages/scripts/i18n-crowdin.ts +++ b/packages/scripts/i18n-crowdin.ts @@ -132,12 +132,19 @@ async function findFileId(filePath: string, branchId?: number): Promise fileData.data); + // Compare directoryId since when the file is placed in the root return files.find((file) => file.directoryId === directoryId && file.name === fileName)?.id; }