From e241b51e1811bc5fb040faee7eee1f10c44bf0dc Mon Sep 17 00:00:00 2001 From: Diego Zilioti Date: Sat, 20 Oct 2018 19:01:10 -0300 Subject: [PATCH] defaultOptions as a function --- js/src/css/index.js | 4 +++- js/src/html/index.js | 4 +++- js/src/javascript/index.js | 4 +++- js/test/node-beautify-tests.js | 11 +++++++---- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/js/src/css/index.js b/js/src/css/index.js index 84a036c33..1f4548212 100644 --- a/js/src/css/index.js +++ b/js/src/css/index.js @@ -37,4 +37,6 @@ function css_beautify(source_text, options) { } module.exports = css_beautify; -module.exports.defaultOptions = new Options(); +module.exports.defaultOptions = function() { + return new Options(); +}; \ No newline at end of file diff --git a/js/src/html/index.js b/js/src/html/index.js index ec82c514b..e64178fdc 100644 --- a/js/src/html/index.js +++ b/js/src/html/index.js @@ -37,4 +37,6 @@ function style_html(html_source, options, js_beautify, css_beautify) { } module.exports = style_html; -module.exports.defaultOptions = new Options(); +module.exports.defaultOptions = function() { + return new Options(); +}; \ No newline at end of file diff --git a/js/src/javascript/index.js b/js/src/javascript/index.js index 9358fcab7..2216794d4 100644 --- a/js/src/javascript/index.js +++ b/js/src/javascript/index.js @@ -37,4 +37,6 @@ function js_beautify(js_source_text, options) { } module.exports = js_beautify; -module.exports.defaultOptions = new Options(); +module.exports.defaultOptions = function() { + return new Options(); +}; \ No newline at end of file diff --git a/js/test/node-beautify-tests.js b/js/test/node-beautify-tests.js index b0bfa3433..3767674e4 100755 --- a/js/test/node-beautify-tests.js +++ b/js/test/node-beautify-tests.js @@ -19,14 +19,17 @@ function test_legacy_names() { results.expect(typeof beautify.html, 'function'); console.log('Ensure defaultOptions are defined'); - results.expect(typeof beautify.js.defaultOptions, 'object'); - results.expect(typeof beautify.css.defaultOptions, 'object'); - results.expect(typeof beautify.html.defaultOptions, 'object'); + results.expect(typeof beautify.js.defaultOptions, 'function'); + results.expect(typeof beautify.css.defaultOptions, 'function'); + results.expect(typeof beautify.html.defaultOptions, 'function'); console.log('Ensure that legacy import names equal the new ones'); results.expect(beautify.js, beautify.js_beautify); results.expect(beautify.css, beautify.css_beautify); results.expect(beautify.html, beautify.html_beautify); + results.expect(beautify.js.defaultOptions, beautify.js_beautify.defaultOptions); + results.expect(beautify.css.defaultOptions, beautify.css_beautify.defaultOptions); + results.expect(beautify.html.defaultOptions, beautify.html_beautify.defaultOptions); console.log(results.results_raw()); return results.get_exitcode(); @@ -75,4 +78,4 @@ if (require.main === module) { exit = exit || node_beautifier_bundle_tests('html-beautifier', run_html_tests); process.exit(exit); -} +} \ No newline at end of file