From a5b8f6e6c6713c2e77e83235b2c04a4b22bdbf73 Mon Sep 17 00:00:00 2001 From: Kim Biesbjerg Date: Fri, 2 Aug 2019 13:34:18 +0200 Subject: [PATCH] (bugfix) order of keys was not preserved when using namespaced-json format. Closes #131 --- package-lock.json | 7 +++---- package.json | 2 +- tests/compilers/namespaced-json.compiler.spec.ts | 9 +++++++++ 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 916615c..c1c304d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@biesbjerg/ngx-translate-extract", - "version": "2.3.4", + "version": "3.0.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -512,9 +512,8 @@ } }, "flat": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/flat/-/flat-4.1.0.tgz", - "integrity": "sha512-Px/TiLIznH7gEDlPXcUD4KnBusa6kR6ayRUVcnEAbreRIuhkqow/mun59BuRXwoYk7ZQOLW1ZM05ilIvK38hFw==", + "version": "git://github.com/lenchvolodymyr/flat.git#ffe77efe8c33bc80ffb2f7a465537610dea4f611", + "from": "git://github.com/lenchvolodymyr/flat.git#ffe77ef", "requires": { "is-buffer": "~2.0.3" } diff --git a/package.json b/package.json index 904bec2..835aa8a 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "@angular/compiler": "^8.1.3", "boxen": "^4.1.0", "colorette": "^1.1.0", - "flat": "^4.1.0", + "flat": "git://github.com/lenchvolodymyr/flat.git#ffe77ef", "gettext-parser": "^4.0.1", "glob": "^7.1.4", "mkdirp": "^0.5.1", diff --git a/tests/compilers/namespaced-json.compiler.spec.ts b/tests/compilers/namespaced-json.compiler.spec.ts index 8ca093a..df7d68e 100644 --- a/tests/compilers/namespaced-json.compiler.spec.ts +++ b/tests/compilers/namespaced-json.compiler.spec.ts @@ -57,4 +57,13 @@ describe('NamespacedJsonCompiler', () => { expect(result).to.equal('{\n "NAMESPACE": {\n "KEY": {\n "FIRST_KEY": "",\n "SECOND_KEY": "VALUE"\n }\n }\n}'); }); + it('should not reorder keys when compiled', () => { + const collection = new TranslationCollection({ + 'BROWSE': '', + 'LOGIN': '' + }); + const result: string = compiler.compile(collection); + expect(result).to.equal('{\n\t"BROWSE": "",\n\t"LOGIN": ""\n}'); + }); + });