mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-23 11:44:06 -08:00
⚡ Refactor gulpfile
This commit is contained in:
parent
7518617eee
commit
ed4f9a5e68
|
@ -20,7 +20,14 @@ task('build:translations', writeHeadersAndTranslations);
|
|||
* each node translation at `/dist/nodes/<node>/translations/<language>.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('')
|
||||
['\033[', ansiColorCode, 'm', string, '\033[0m'].join('');
|
||||
|
|
Loading…
Reference in a new issue