node-properties icon indicating copy to clipboard operation
node-properties copied to clipboard

line wrapping in properties files

Open pohutukawa opened this issue 4 years ago • 2 comments

I've been looking and trying like crazy, but I can't find an option to allow for value continuation in the following line by adding backslash \ at the end of a line.

This is specified and allowed in the Java .properties specification, and we're using a .properties file between Java and TypeScript properties as a common/shared set of test vectors to keep the implementations consistent. Unfortunately this package doesn't support that feature (e.g. for keeping JSON values tidy across several lines), so there's always the danger of introducing errors through this.

Is there a possibility this feature may make its way into the properties module?

pohutukawa avatar Nov 12 '20 02:11 pohutukawa

Feel free to make any changes. I'll be happy to add them. -------- Original message --------From: Guy Kloss [email protected] Date: 11/12/20 03:43 (GMT+01:00) To: gagle/node-properties [email protected] Cc: Subscribed [email protected] Subject: [gagle/node-properties] line wrapping in properties files (#34) I've been looking and trying like crazy, but I can't find an option to allow for value continuation in the following line by adding backslash \ at the end of a line. This is specified and allowed in the Java .properties specification, and we're using a .properties file between Java and TypeScript properties as a common/shared set of test vectors to keep the implementations consistent. Unfortunately this package doesn't support that feature (e.g. for keeping JSON values tidy across several lines), so there's always the danger of introducing errors through this. Is there a possibility this feature may make its way into the properties module?

—You are receiving this because you are subscribed to this thread.Reply to this email directly, view it on GitHub, or unsubscribe.

gagle avatar Nov 12 '20 05:11 gagle

I would if I had the skills for JS/TS. I'm more of a Python or Java person. I had looked at node-properties as it advertises to be spec compatible, and the test vectors in the .properties file come from Java.

However, I have been able to solve the problem with a work-around. Maybe it helps others with the same kind of problems.

let propContent = fs.readFileSync('./test/test-data.properties', 'utf8');
propContent = propContent.replace(`\\$`, '\n');
const myProperties = properties.parse(propContent);

pohutukawa avatar Nov 16 '20 19:11 pohutukawa