Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #1457, int val output in TOML format, adds test #1458

Merged
merged 6 commits into from
Jun 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/formats/__tests__/tomlFormatter.spec.js
Original file line number Diff line number Diff line change
@@ -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')
);
});
});
4 changes: 4 additions & 0 deletions src/formats/toml.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down