mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-11 12:57:29 -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`
|
* each node translation at `/dist/nodes/<node>/translations/<language>.js`
|
||||||
*/
|
*/
|
||||||
function writeHeadersAndTranslations(done) {
|
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 paths = getTranslationPaths();
|
||||||
const { headers, translations } = getHeadersAndTranslations(paths);
|
const { headers, translations } = getHeadersAndTranslations(paths);
|
||||||
|
@ -108,17 +115,6 @@ function isValidHeader(header, allowedHeaderKeys) {
|
||||||
headerKeys.every(key => allowedHeaderKeys.includes(key));
|
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) {
|
function writeDestinationFile(destinationPath, data) {
|
||||||
writeFile(
|
writeFile(
|
||||||
destinationPath,
|
destinationPath,
|
||||||
|
@ -138,4 +134,4 @@ const log = (string, { bulletpoint } = { bulletpoint: false }) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const colorize = (ansiColorCode, string) =>
|
const colorize = (ansiColorCode, string) =>
|
||||||
['\033[', ansiColorCode, 'm', string, '\033[0m'].join('')
|
['\033[', ansiColorCode, 'm', string, '\033[0m'].join('');
|
||||||
|
|
Loading…
Reference in a new issue