From 73c06a5d71a8d5a5c859fceb2fbd2e3fc0fead3e Mon Sep 17 00:00:00 2001 From: Oliver Eyton-Williams Date: Wed, 3 Feb 2021 10:46:27 +0100 Subject: [PATCH] refactor: tidy up translation-parser --- curriculum/getChallenges.js | 2 +- .../translation-parser/{translation-parser.js => index.js} | 5 ++--- .../{translation-parser.test.js => index.test.js} | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) rename tools/challenge-parser/translation-parser/{translation-parser.js => index.js} (97%) rename tools/challenge-parser/translation-parser/{translation-parser.test.js => index.test.js} (99%) diff --git a/curriculum/getChallenges.js b/curriculum/getChallenges.js index d87c47f716..deeb62b646 100644 --- a/curriculum/getChallenges.js +++ b/curriculum/getChallenges.js @@ -8,7 +8,7 @@ const util = require('util'); /* eslint-disable max-len */ const { translateCommentsInChallenge -} = require('../tools/challenge-parser/translation-parser/translation-parser'); +} = require('../tools/challenge-parser/translation-parser'); /* eslint-enable max-len*/ const { isAuditedCert } = require('../utils/is-audited'); diff --git a/tools/challenge-parser/translation-parser/translation-parser.js b/tools/challenge-parser/translation-parser/index.js similarity index 97% rename from tools/challenge-parser/translation-parser/translation-parser.js rename to tools/challenge-parser/translation-parser/index.js index 5589f93aa0..69e2807276 100644 --- a/tools/challenge-parser/translation-parser/translation-parser.js +++ b/tools/challenge-parser/translation-parser/index.js @@ -1,5 +1,4 @@ -const { isEmpty } = require('lodash'); -const clone = require('lodash/cloneDeep'); +const { isEmpty, cloneDeep } = require('lodash'); exports.translateComments = (text, lang, dict, codeLang) => { const knownComments = Object.keys(dict); @@ -16,7 +15,7 @@ exports.translateComments = (text, lang, dict, codeLang) => { }; exports.translateCommentsInChallenge = (challenge, lang, dict) => { - const challClone = clone(challenge); + const challClone = cloneDeep(challenge); if (!challClone.files) { console.warn(`Challenge ${challClone.title} has no comments to translate`); } else { diff --git a/tools/challenge-parser/translation-parser/translation-parser.test.js b/tools/challenge-parser/translation-parser/index.test.js similarity index 99% rename from tools/challenge-parser/translation-parser/translation-parser.test.js rename to tools/challenge-parser/translation-parser/index.test.js index 47a1a97806..cf45179add 100644 --- a/tools/challenge-parser/translation-parser/translation-parser.test.js +++ b/tools/challenge-parser/translation-parser/index.test.js @@ -3,7 +3,7 @@ const { mergeChallenges, translateComments, translateCommentsInChallenge -} = require('./translation-parser'); +} = require('.'); const { ENGLISH_CERTIFICATE, ENGLISH_CHALLENGE,