Add cli option to customize compiler indentation. Closes #22

This commit is contained in:
Kim Biesbjerg
2017-03-29 14:20:01 +02:00
parent ff1c91010e
commit 9a2108e9a9
9 changed files with 97 additions and 47 deletions

View File

@@ -45,4 +45,16 @@ describe('NamespacedJsonCompiler', () => {
expect(result).to.equal('{\n\t"option": {\n\t\t"0": "",\n\t\t"1": "",\n\t\t"2": ""\n\t}\n}');
});
it('should use custom indentation chars', () => {
const collection = new TranslationCollection({
'NAMESPACE.KEY.FIRST_KEY': '',
'NAMESPACE.KEY.SECOND_KEY': 'VALUE'
});
const customCompiler = new NamespacedJsonCompiler({
indentation: ' '
});
const result: string = customCompiler.compile(collection);
expect(result).to.equal('{\n "NAMESPACE": {\n "KEY": {\n "FIRST_KEY": "",\n "SECOND_KEY": "VALUE"\n }\n }\n}');
});
});