diff --git a/src/formats/__tests__/tomlFormatter.spec.js b/src/formats/__tests__/tomlFormatter.spec.js new file mode 100644 index 00000000..54d39896 --- /dev/null +++ b/src/formats/__tests__/tomlFormatter.spec.js @@ -0,0 +1,15 @@ +import tomlFormatter from '../toml'; + +describe('tomlFormatter', () => { + it('should output TOML integer values without decimals', () => { + expect( + tomlFormatter.toFile({ testFloat: 123.456, testInteger: 789, title: 'TOML' }) + ).toEqual( + [ + 'testFloat = 123.456', + 'testInteger = 789', + 'title = "TOML"' + ].join('\n') + ); + }); +}); diff --git a/src/formats/toml.js b/src/formats/toml.js index 43863474..82a532c4 100644 --- a/src/formats/toml.js +++ b/src/formats/toml.js @@ -11,6 +11,10 @@ const outputReplacer = (key, value) => { if (value instanceof AssetProxy) { return `${ value.path }`; } + if (Number.isInteger(value)) { + // Return the string representation of integers so tomlify won't render with tenths (".0") + return value.toString(); + } // Return `false` to use default (`undefined` would delete key). return false; };