Skip to content

Commit

Permalink
Use tree-house-translations module
Browse files Browse the repository at this point in the history
  • Loading branch information
knor-el-snor committed May 2, 2018
1 parent 3ba8679 commit 1110434
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 137 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Treehouse Errors
# Treehouse errors

Custom NodeJS error classes and definitions with an error parser utility function

Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@
],
"dependencies": {
"express-validation": "~1.0.2",
"http-status": "~1.0.1",
"http-status": "~1.1.0",
"i18n": "~0.8.3",
"joi": "~13.2.0",
"tree-house-translations": "~1.0.1",
"uuid": "~3.2.1"
},
"devDependencies": {
"@types/http-status": "~0.2.30",
"@types/i18n": "~0.8.3",
"@types/jest": "~22.2.0",
"@types/uuid": "~3.4.3",
"coveralls": "^3.0.0",
"icapps-translations": "^0.0.15",
"coveralls": "^3.0.1",
"jest": "^22.1.4",
"np": "^2.20.1",
"pre-commit": "^1.2.2",
Expand Down
5 changes: 3 additions & 2 deletions src/lib/importer.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as icappsTranslation from 'icapps-translations';
import * as icappsTranslation from 'tree-house-translations';
import { existsSync, mkdirSync } from 'fs';

const defaultOptions = {
const defaultOptions = <any> {
destination: process.cwd() + '/locales',
clean: true,
seperateCategories: false,
Expand All @@ -10,6 +10,7 @@ const defaultOptions = {

export async function importTranslations(url: string, token: string, options?: TranslationOptions) {
const allOptions = Object.assign({}, defaultOptions, options);

// if locales location does not exists, make directory
if (!existsSync(allOptions.destination)) {
mkdirSync(allOptions.destination);
Expand Down
4 changes: 2 additions & 2 deletions tests/importer.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { importTranslations } from '../src';
import * as icappsTranslation from 'icapps-translations';
import * as icappsTranslation from 'tree-house-translations';
import { existsSync, rmdirSync, mkdirSync } from 'fs';

describe('importTranslations', () => {
Expand All @@ -14,7 +14,7 @@ describe('importTranslations', () => {
});

it('should import the translations', async () => {
await importTranslations('http://test.be', 'randomToken');
await importTranslations('http://test.be', 'randomToken', { destination: './locales' });
expect(icappsTranslationMock).toHaveBeenCalledTimes(1);
rmdirSync('./locales'); // cleanup
});
Expand Down
Loading

0 comments on commit 1110434

Please sign in to comment.