From ed4f9a5e6838e59c4e012cc2d72114011bc363c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Ovejero?= Date: Fri, 19 Nov 2021 16:08:43 +0100 Subject: [PATCH] :zap: Refactor gulpfile --- packages/nodes-base/gulpfile.js | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/packages/nodes-base/gulpfile.js b/packages/nodes-base/gulpfile.js index e67207e150..495ca8d1c7 100644 --- a/packages/nodes-base/gulpfile.js +++ b/packages/nodes-base/gulpfile.js @@ -20,7 +20,14 @@ task('build:translations', writeHeadersAndTranslations); * each node translation at `/dist/nodes//translations/.js` */ function writeHeadersAndTranslations(done) { - checkLocale(); + const { N8N_DEFAULT_LOCALE: locale } = process.env; + + log(`Default locale set to: ${colorize(PURPLE_ANSI_COLOR_CODE, locale || 'en')}`); + + if (!locale || locale === 'en') { + log('No translation required - Skipping translations build...'); + return done(); + }; const paths = getTranslationPaths(); const { headers, translations } = getHeadersAndTranslations(paths); @@ -108,17 +115,6 @@ function isValidHeader(header, allowedHeaderKeys) { headerKeys.every(key => allowedHeaderKeys.includes(key)); } -function checkLocale() { - const { N8N_DEFAULT_LOCALE: locale } = process.env; - - log(`Default locale set to: ${colorize(PURPLE_ANSI_COLOR_CODE, locale || 'en')}`); - - if (!locale || locale === 'en') { - log('No translation required - Skipping translations build...'); - return; - }; -} - function writeDestinationFile(destinationPath, data) { writeFile( destinationPath, @@ -138,4 +134,4 @@ const log = (string, { bulletpoint } = { bulletpoint: false }) => { }; const colorize = (ansiColorCode, string) => - ['\033[', ansiColorCode, 'm', string, '\033[0m'].join('') \ No newline at end of file + ['\033[', ansiColorCode, 'm', string, '\033[0m'].join('');