steveukx / properties

Properties reader for Node.js
MIT License
77 stars 33 forks source link

Allow to write without sections #24

Closed Andreas-Schoenefeldt closed 4 years ago

Andreas-Schoenefeldt commented 5 years ago

Hi @steveukx, thx a lot for this super usefull library!

In my project I need property files without the section feature, so I would be greatfull, if you could review and maybe merge this PR.

In a nutshell it makes it possible to initalize the reader now like this, in order to prevent sections on writing:

const props = new PropertiesReader(filePath, {write_sections: false});
await props.save(filePath);

Please let me know, if you're not happy with the way I introduced options - I thought it the least disturbing for projects already depending on the current code.

Best wishes! Andreas

JoeFirebaugh commented 4 years ago

I would love to have this feature as I'm reading and hopefully writing Java property files, thanks.

LeonardoPortoTR commented 4 years ago

I would love to have this feature too, that's exactly what I need

Andreas-Schoenefeldt commented 4 years ago

@steveukx, any chance this can be merged? If yes I'm happy to resolve the conflicts :)

steveukx commented 4 years ago

Apologies for not having followed this thread. Since this PR was opened, the library was updated to allow for using a custom property appender (for use when calling properties.set(...).

I've made a similar change now (available on npm as version 2.1.1) that allows providing writer properties. To achieve this you can now call:

const propertiesReader = require('properties-reader');
const props = propertiesReader(filePath, 'utf-8', { writer: { saveSections: false } });