Skip to content

Commit

Permalink
defaultOptions as a function
Browse files Browse the repository at this point in the history
  • Loading branch information
zilioti committed Oct 20, 2018
1 parent 7ed4a77 commit 5e52800
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
4 changes: 3 additions & 1 deletion js/src/css/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
};
4 changes: 3 additions & 1 deletion js/src/html/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
};
4 changes: 3 additions & 1 deletion js/src/javascript/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
};
9 changes: 6 additions & 3 deletions js/test/node-beautify-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 5e52800

Please sign in to comment.