Draft for defaultOptions

This commit is contained in:
Diego Zilioti 2018-10-06 19:15:01 -03:00
parent d98c27bcf2
commit 88fd75760e
5 changed files with 18 additions and 6 deletions

View File

@ -28,11 +28,13 @@
'use strict';
var Beautifier = require('./beautifier').Beautifier;
var Beautifier = require('./beautifier').Beautifier,
Options = require('./options').Options;
function css_beautify(source_text, options) {
var beautifier = new Beautifier(source_text, options);
return beautifier.beautify();
}
module.exports = css_beautify;
module.exports = css_beautify;
module.exports.defaultOptions = new Options();

View File

@ -28,11 +28,13 @@
'use strict';
var Beautifier = require('./beautifier').Beautifier;
var Beautifier = require('./beautifier').Beautifier,
Options = require('./options').Options;
function style_html(html_source, options, js_beautify, css_beautify) {
var beautifier = new Beautifier(html_source, options, js_beautify, css_beautify);
return beautifier.beautify();
}
module.exports = style_html;
module.exports = style_html;
module.exports.defaultOptions = new Options();

View File

@ -37,6 +37,7 @@ function style_html(html_source, options, js, css) {
css = css || css_beautify;
return html_beautify(html_source, options, js, css);
}
style_html.defaultOptions = html_beautify.defaultOptions;
module.exports.js = js_beautify;
module.exports.css = css_beautify;

View File

@ -28,11 +28,13 @@
'use strict';
var Beautifier = require('./beautifier').Beautifier;
var Beautifier = require('./beautifier').Beautifier,
Options = require('./options').Options;
function js_beautify(js_source_text, options) {
var beautifier = new Beautifier(js_source_text, options);
return beautifier.beautify();
}
module.exports = js_beautify;
module.exports = js_beautify;
module.exports.defaultOptions = new Options();

View File

@ -18,6 +18,11 @@ function test_legacy_names() {
results.expect(typeof beautify.css, 'function');
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');
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);