From 01db7f4a5ba44283981adee1edb196e870f7bcd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Ovejero?= Date: Thu, 2 Dec 2021 13:38:29 +0100 Subject: [PATCH] :fire: Replace require() to prevent caching --- packages/cli/src/Server.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/Server.ts b/packages/cli/src/Server.ts index 45ac58175f..4b764af2e3 100644 --- a/packages/cli/src/Server.ts +++ b/packages/cli/src/Server.ts @@ -29,6 +29,7 @@ import * as express from 'express'; import { readFileSync, existsSync } from 'fs'; +import { readFile } from 'fs/promises'; import { dirname as pathDirname, join as pathJoin, resolve as pathResolve } from 'path'; import { FindManyOptions, getConnectionManager, In, IsNull, LessThanOrEqual, Not } from 'typeorm'; import * as bodyParser from 'body-parser'; @@ -1197,8 +1198,13 @@ class App { for (const { name, version } of nodeInfos) { const { description, sourcePath } = NodeTypes().getWithSourcePath(name, version); const translationPath = await getNodeTranslationPath(sourcePath, defaultLocale); - if (existsSync(translationPath)) { - description.translation = require(translationPath); + + try { + const translation = await readFile(translationPath, 'utf8'); + description.translation = JSON.parse(translation); + // eslint-disable-next-line no-empty + } catch (error) { + // file not accessible } nodeTypes.push(description); }