Skip to content

Commit

Permalink
fix(i18n): remove mustache dependency (#1884)
Browse files Browse the repository at this point in the history
  • Loading branch information
addaleax authored Mar 25, 2024
1 parent e99bbbe commit b9bb515
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 41 deletions.
31 changes: 1 addition & 30 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions packages/i18n/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,12 @@
"unitTestsOnly": true
},
"dependencies": {
"@mongosh/errors": "0.0.0-dev.0",
"mustache": "^4.0.0"
"@mongosh/errors": "0.0.0-dev.0"
},
"devDependencies": {
"@mongodb-js/eslint-config-mongosh": "^1.0.0",
"@mongodb-js/prettier-config-devtools": "^1.0.1",
"@mongodb-js/tsconfig-mongosh": "^1.0.0",
"@types/mustache": "^4.0.1",
"depcheck": "^1.4.3",
"eslint": "^7.25.0",
"prettier": "^2.8.8"
Expand Down
11 changes: 3 additions & 8 deletions packages/i18n/src/translator.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { MongoshInternalError } from '@mongosh/errors';
import Mustache from 'mustache';
import type Catalog from './catalog';
import de_DE from './locales/de_DE';
import en_US from './locales/en_US';
Expand All @@ -17,12 +16,6 @@ const MAPPINGS: Record<string, Catalog> = {
de_DE: de_DE,
};

/**
* The help template.
*/
const TEMPLATE =
'{{description}}\n\n' + '{{link}}\n\n' + '{{example}}\n\n' + '{{returns}}';

/**
* The translator class.
*/
Expand Down Expand Up @@ -102,7 +95,9 @@ class Translator {
if (typeof value === 'string') {
return value;
}
return Mustache.render(TEMPLATE, value);

const { description = '', link = '', example = '', returns = '' } = value;
return `${description}\n\n${link}\n\n${example}\n\n${returns}`;
}

private find(key: string): string | undefined {
Expand Down

0 comments on commit b9bb515

Please sign in to comment.