From fdfee956e3e9404d667377a878b423f7ba6b4d0c Mon Sep 17 00:00:00 2001 From: Adriano Raiano Date: Sun, 2 Jan 2022 12:26:20 +0100 Subject: [PATCH] adapt newlines for windows in tests --- test/fixtures/index.js | 44 +++++++++++++------------- test/fixtures/inline-elements/index.js | 40 +++++++++++------------ 2 files changed, 42 insertions(+), 42 deletions(-) diff --git a/test/fixtures/index.js b/test/fixtures/index.js index f7a5419..5192df1 100644 --- a/test/fixtures/index.js +++ b/test/fixtures/index.js @@ -4,12 +4,12 @@ const path = require('path') module.exports = { example: { js: require('./example.json'), - xliff: fs.readFileSync(path.join(__dirname, 'example.xliff')).toString().replace(/\n$/, '').replace(/\r$/, ''), - xliff_output_notes: fs.readFileSync(path.join(__dirname, 'example_output_note.xliff')).toString().replace(/\n$/, '').replace(/\r$/, ''), - xliff_compact: fs.readFileSync(path.join(__dirname, 'example_compact.xliff')).toString().replace(/\n$/, '').replace(/\r$/, ''), - xliff12: fs.readFileSync(path.join(__dirname, 'example12.xliff')).toString().replace(/\n$/, '').replace(/\r$/, ''), - xliff12_output_notes: fs.readFileSync(path.join(__dirname, 'example12_output_note.xliff')).toString().replace(/\n$/, '').replace(/\r$/, ''), - xliff12_compact: fs.readFileSync(path.join(__dirname, 'example_compact12.xliff')).toString().replace(/\n$/, '').replace(/\r$/, ''), + xliff: fs.readFileSync(path.join(__dirname, 'example.xliff')).toString().replace(/(\r\n$|\r$|\n$)/, ''), + xliff_output_notes: fs.readFileSync(path.join(__dirname, 'example_output_note.xliff')).toString().replace(/(\r\n$|\r$|\n$)/, ''), + xliff_compact: fs.readFileSync(path.join(__dirname, 'example_compact.xliff')).toString().replace(/(\r\n$|\r$|\n$)/, ''), + xliff12: fs.readFileSync(path.join(__dirname, 'example12.xliff')).toString().replace(/(\r\n$|\r$|\n$)/, ''), + xliff12_output_notes: fs.readFileSync(path.join(__dirname, 'example12_output_note.xliff')).toString().replace(/(\r\n$|\r$|\n$)/, ''), + xliff12_compact: fs.readFileSync(path.join(__dirname, 'example_compact12.xliff')).toString().replace(/(\r\n$|\r$|\n$)/, ''), js_source: require('./example_source.json'), js_target: require('./example_target.json'), js_input_notes: require('./example_input_note.json'), @@ -17,50 +17,50 @@ module.exports = { }, example_source_attr: { // The JS should be the same as example.js - xliff12: fs.readFileSync(path.join(__dirname, 'example_source_attr12.xliff')).toString().replace(/\n$/, '').replace(/\r$/, '') + xliff12: fs.readFileSync(path.join(__dirname, 'example_source_attr12.xliff')).toString().replace(/(\r\n$|\r$|\n$)/, '') }, example_multi: { js: require('./example_multi.json'), - xliff: fs.readFileSync(path.join(__dirname, 'example_multi.xliff')).toString().replace(/\n$/, '').replace(/\r$/, ''), - xliff12: fs.readFileSync(path.join(__dirname, 'example_multi12.xliff')).toString().replace(/\n$/, '').replace(/\r$/, ''), + xliff: fs.readFileSync(path.join(__dirname, 'example_multi.xliff')).toString().replace(/(\r\n$|\r$|\n$)/, ''), + xliff12: fs.readFileSync(path.join(__dirname, 'example_multi12.xliff')).toString().replace(/(\r\n$|\r$|\n$)/, ''), js_source: require('./example_multi_source.json'), js_target: require('./example_multi_target.json') }, example_note: { js: require('./example_note.json'), - xliff: fs.readFileSync(path.join(__dirname, 'example_note.xliff')).toString().replace(/\n$/, '').replace(/\r$/, ''), - xliff12: fs.readFileSync(path.join(__dirname, 'example_note12.xliff')).toString().replace(/\n$/, '').replace(/\r$/, '') + xliff: fs.readFileSync(path.join(__dirname, 'example_note.xliff')).toString().replace(/(\r\n$|\r$|\n$)/, ''), + xliff12: fs.readFileSync(path.join(__dirname, 'example_note12.xliff')).toString().replace(/(\r\n$|\r$|\n$)/, '') }, example_additional_attributes: { js: require('./example_additional_attributes'), - xliff: fs.readFileSync(path.join(__dirname, 'example_additional_attributes.xliff')).toString().replace(/\n$/, '').replace(/\r$/, ''), - xliff12: fs.readFileSync(path.join(__dirname, 'example_additional_attributes12.xliff')).toString().replace(/\n$/, '').replace(/\r$/, '') + xliff: fs.readFileSync(path.join(__dirname, 'example_additional_attributes.xliff')).toString().replace(/(\r\n$|\r$|\n$)/, ''), + xliff12: fs.readFileSync(path.join(__dirname, 'example_additional_attributes12.xliff')).toString().replace(/(\r\n$|\r$|\n$)/, '') }, example_angular: { js: require('./example_angular'), - xliff: fs.readFileSync(path.join(__dirname, 'example_angular.xliff')).toString().replace(/\n$/, '').replace(/\r$/, ''), - xliff12: fs.readFileSync(path.join(__dirname, 'example_angular12.xliff')).toString().replace(/\n$/, '').replace(/\r$/, '') + xliff: fs.readFileSync(path.join(__dirname, 'example_angular.xliff')).toString().replace(/(\r\n$|\r$|\n$)/, ''), + xliff12: fs.readFileSync(path.join(__dirname, 'example_angular12.xliff')).toString().replace(/(\r\n$|\r$|\n$)/, '') }, example_google: { js: require('./example_google_action'), - xliff12: fs.readFileSync(path.join(__dirname, 'example_google_action.xliff')).toString().replace(/\n$/, '').replace(/\r$/, '') + xliff12: fs.readFileSync(path.join(__dirname, 'example_google_action.xliff')).toString().replace(/(\r\n$|\r$|\n$)/, '') }, example_groups: { js: require('./example_groups'), - xliff: fs.readFileSync(path.join(__dirname, 'example_groups.xliff')).toString().replace(/\n$/, '').replace(/\r$/, ''), - xliff12: fs.readFileSync(path.join(__dirname, 'example_groups12.xliff')).toString().replace(/\n$/, '').replace(/\r$/, '') + xliff: fs.readFileSync(path.join(__dirname, 'example_groups.xliff')).toString().replace(/(\r\n$|\r$|\n$)/, ''), + xliff12: fs.readFileSync(path.join(__dirname, 'example_groups12.xliff')).toString().replace(/(\r\n$|\r$|\n$)/, '') }, example_cdata: { js: require('./example_cdata'), - xliff: fs.readFileSync(path.join(__dirname, 'example_cdata.xliff')).toString().replace(/\n$/, '').replace(/\r$/, ''), - xliff12: fs.readFileSync(path.join(__dirname, 'example_cdata12.xliff')).toString().replace(/\n$/, '').replace(/\r$/, '') + xliff: fs.readFileSync(path.join(__dirname, 'example_cdata.xliff')).toString().replace(/(\r\n$|\r$|\n$)/, ''), + xliff12: fs.readFileSync(path.join(__dirname, 'example_cdata12.xliff')).toString().replace(/(\r\n$|\r$|\n$)/, '') }, example_comments: { js: require('./example_comments'), - xliff: fs.readFileSync(path.join(__dirname, 'example_comments.xliff')).toString().replace(/\n$/, '').replace(/\r$/, '') + xliff: fs.readFileSync(path.join(__dirname, 'example_comments.xliff')).toString().replace(/(\r\n$|\r$|\n$)/, '') }, example_ignorable: { js: require('./example_ignorable'), - xliff: fs.readFileSync(path.join(__dirname, 'example_ignorable.xliff')).toString().replace(/\n$/, '').replace(/\r$/, '') + xliff: fs.readFileSync(path.join(__dirname, 'example_ignorable.xliff')).toString().replace(/(\r\n$|\r$|\n$)/, '') } } diff --git a/test/fixtures/inline-elements/index.js b/test/fixtures/inline-elements/index.js index 27bc40e..2741fd7 100644 --- a/test/fixtures/inline-elements/index.js +++ b/test/fixtures/inline-elements/index.js @@ -4,61 +4,61 @@ const path = require('path') module.exports = { example_standalone: { js: require('./example_standalone.json'), - xliff: fs.readFileSync(path.join(__dirname, 'example_standalone.xliff')).toString().replace(/\n$/, '').replace(/\r$/, ''), - xliff12: fs.readFileSync(path.join(__dirname, 'example_standalone12.xliff')).toString().replace(/\n$/, '').replace(/\r$/, '') + xliff: fs.readFileSync(path.join(__dirname, 'example_standalone.xliff')).toString().replace(/(\r\n$|\r$|\n$)/, ''), + xliff12: fs.readFileSync(path.join(__dirname, 'example_standalone12.xliff')).toString().replace(/(\r\n$|\r$|\n$)/, '') }, example_standalone_only: { js: require('./example_standalone_only.json'), - xliff: fs.readFileSync(path.join(__dirname, 'example_standalone_only.xliff')).toString().replace(/\n$/, '').replace(/\r$/, ''), - xliff12: fs.readFileSync(path.join(__dirname, 'example_standalone_only12.xliff')).toString().replace(/\n$/, '').replace(/\r$/, '') + xliff: fs.readFileSync(path.join(__dirname, 'example_standalone_only.xliff')).toString().replace(/(\r\n$|\r$|\n$)/, ''), + xliff12: fs.readFileSync(path.join(__dirname, 'example_standalone_only12.xliff')).toString().replace(/(\r\n$|\r$|\n$)/, '') }, example_genericSpan: { js: require('./example_generic-span.json'), - xliff: fs.readFileSync(path.join(__dirname, 'example_generic-span.xliff')).toString().replace(/\n$/, '').replace(/\r$/, ''), - xliff12: fs.readFileSync(path.join(__dirname, 'example_generic-span12.xliff')).toString().replace(/\n$/, '').replace(/\r$/, ''), + xliff: fs.readFileSync(path.join(__dirname, 'example_generic-span.xliff')).toString().replace(/(\r\n$|\r$|\n$)/, ''), + xliff12: fs.readFileSync(path.join(__dirname, 'example_generic-span12.xliff')).toString().replace(/(\r\n$|\r$|\n$)/, ''), js_source: require('./example_generic-span_source.json'), js_target: require('./example_generic-span_target.json') }, example_genericSpanStartEnd: { js: require('./example_generic-span-start-end.json'), - xliff: fs.readFileSync(path.join(__dirname, 'example_generic-span-start-end.xliff')).toString().replace(/\n$/, '').replace(/\r$/, ''), - xliff12: fs.readFileSync(path.join(__dirname, 'example_generic-span-start-end12.xliff')).toString().replace(/\n$/, '').replace(/\r$/, '') + xliff: fs.readFileSync(path.join(__dirname, 'example_generic-span-start-end.xliff')).toString().replace(/(\r\n$|\r$|\n$)/, ''), + xliff12: fs.readFileSync(path.join(__dirname, 'example_generic-span-start-end12.xliff')).toString().replace(/(\r\n$|\r$|\n$)/, '') }, example_nativeSpan: { js: require('./example_native-span.json'), - xliff: fs.readFileSync(path.join(__dirname, 'example_native-span.xliff')).toString().replace(/\n$/, '').replace(/\r$/, ''), - xliff12: fs.readFileSync(path.join(__dirname, 'example_native-span12.xliff')).toString().replace(/\n$/, '').replace(/\r$/, ''), + xliff: fs.readFileSync(path.join(__dirname, 'example_native-span.xliff')).toString().replace(/(\r\n$|\r$|\n$)/, ''), + xliff12: fs.readFileSync(path.join(__dirname, 'example_native-span12.xliff')).toString().replace(/(\r\n$|\r$|\n$)/, ''), js_source: require('./example_native-span_source.json'), js_target: require('./example_native-span_target.json') }, example_nativeSpanStartEnd: { js: require('./example_native-span-start-end.json'), - xliff: fs.readFileSync(path.join(__dirname, 'example_native-span-start-end.xliff')).toString().replace(/\n$/, '').replace(/\r$/, ''), - xliff12: fs.readFileSync(path.join(__dirname, 'example_native-span-start-end12.xliff')).toString().replace(/\n$/, '').replace(/\r$/, '') + xliff: fs.readFileSync(path.join(__dirname, 'example_native-span-start-end.xliff')).toString().replace(/(\r\n$|\r$|\n$)/, ''), + xliff12: fs.readFileSync(path.join(__dirname, 'example_native-span-start-end12.xliff')).toString().replace(/(\r\n$|\r$|\n$)/, '') }, example_invalidSegment: { js: require('./example_invalid-segment.json'), - xliff: fs.readFileSync(path.join(__dirname, 'example_invalid-segment.xliff')).toString().replace(/\n$/, '').replace(/\r$/, ''), - xliff12: fs.readFileSync(path.join(__dirname, 'example_invalid-segment12.xliff')).toString().replace(/\n$/, '').replace(/\r$/, '') + xliff: fs.readFileSync(path.join(__dirname, 'example_invalid-segment.xliff')).toString().replace(/(\r\n$|\r$|\n$)/, ''), + xliff12: fs.readFileSync(path.join(__dirname, 'example_invalid-segment12.xliff')).toString().replace(/(\r\n$|\r$|\n$)/, '') }, // Examples showing how this could work with i18next example_i18next_nativeSpan: { js: require('./example_i18next_native-span.json'), - xliff12: fs.readFileSync(path.join(__dirname, 'example_i18next_native-span12.xliff')).toString().replace(/\n$/, '').replace(/\r$/, '') + xliff12: fs.readFileSync(path.join(__dirname, 'example_i18next_native-span12.xliff')).toString().replace(/(\r\n$|\r$|\n$)/, '') }, example_i18next_unstructured_nativeSpan: { js: require('./example_i18next_unstructured_native-span.json'), - xliff12: fs.readFileSync(path.join(__dirname, 'example_i18next_unstructured_native-span12.xliff')).toString().replace(/\n$/, '').replace(/\r$/, '') + xliff12: fs.readFileSync(path.join(__dirname, 'example_i18next_unstructured_native-span12.xliff')).toString().replace(/(\r\n$|\r$|\n$)/, '') }, example_marker: { js: require('./example_marker.json'), - xliff12: fs.readFileSync(path.join(__dirname, 'example_marker12.xliff')).toString().replace(/\n$/, '').replace(/\r$/, '') + xliff12: fs.readFileSync(path.join(__dirname, 'example_marker12.xliff')).toString().replace(/(\r\n$|\r$|\n$)/, '') }, // angular example_angular: { js: require('./example_angular.json'), - xliff: fs.readFileSync(path.join(__dirname, 'example_angular.xliff')).toString().replace(/\n$/, '').replace(/\r$/, ''), - xliff12: fs.readFileSync(path.join(__dirname, 'example_angular12.xliff')).toString().replace(/\n$/, '').replace(/\r$/, ''), - xliff12ident: fs.readFileSync(path.join(__dirname, 'example_angular12_ident.xliff')).toString().replace(/\n$/, '').replace(/\r$/, '') + xliff: fs.readFileSync(path.join(__dirname, 'example_angular.xliff')).toString().replace(/(\r\n$|\r$|\n$)/, ''), + xliff12: fs.readFileSync(path.join(__dirname, 'example_angular12.xliff')).toString().replace(/(\r\n$|\r$|\n$)/, ''), + xliff12ident: fs.readFileSync(path.join(__dirname, 'example_angular12_ident.xliff')).toString().replace(/(\r\n$|\r$|\n$)/, '') } }