From 591430012b7ddd2eb589c8488cd78878463312f9 Mon Sep 17 00:00:00 2001 From: Jakub Pawlowicz Date: Fri, 13 Jan 2017 12:05:39 +0100 Subject: [PATCH] See #799 - renames `beautify` option to `format`. Why: * It makes more sense as it controls formatting in general; * see #209 where `beautify` was introduced. --- History.md | 2 +- README.md | 20 +++--- bin/cleancss | 12 ++-- lib/clean.js | 4 +- lib/optimizer/level-1/optimize.js | 4 +- lib/optimizer/level-1/tidy-rules.js | 10 +-- lib/options/{beautify.js => format.js} | 4 +- lib/writer/helpers.js | 26 ++++---- lib/writer/simple.js | 2 +- lib/writer/source-maps.js | 2 +- test/batch-test.js | 6 +- test/binary-test.js | 2 +- test/integration-test.js | 10 +-- .../{beatutify-test.js => format-test.js} | 64 +++++++++---------- test/source-map-test.js | 2 +- 15 files changed, 85 insertions(+), 85 deletions(-) rename lib/options/{beautify.js => format.js} (98%) rename test/options/{beatutify-test.js => format-test.js} (76%) diff --git a/History.md b/History.md index 349cfe15..678bc53f 100644 --- a/History.md +++ b/History.md @@ -12,7 +12,7 @@ * Re-enables `background-(clip|origin|size)` merging with `background` shorthand. * Simplifies URL rebasing with a single `rebaseTo` option in API or inferred from `--output` in CLI. * Splits `inliner` option into `inlineRequest` and `inlineTimeout`. -* Fixed issue [#209](https://github.com/jakubpawlowicz/clean-css/issues/209) - adds output formatting via `beautify` flag. +* Fixed issue [#209](https://github.com/jakubpawlowicz/clean-css/issues/209) - adds output formatting via `format` flag. * Fixed issue [#432](https://github.com/jakubpawlowicz/clean-css/issues/432) - adds URLs normalization. * Fixed issue [#460](https://github.com/jakubpawlowicz/clean-css/issues/460) - unescaped semicolon in selector. * Fixed issue [#657](https://github.com/jakubpawlowicz/clean-css/issues/657) - adds property name validation. diff --git a/README.md b/README.md index 28a35c23..e8f6d641 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ There will be some breaking changes: * moves `roundingPrecision` and `specialComments` to level 1 optimizations options, see examples below; * moves `mediaMerging`, `restructuring`, `semanticMerging`, and `shorthandCompacting` to level 2 optimizations options, see examples below; * level 1 optimizations are the new default, up to 3.x it was level 2; -* `--keep-line-breaks` / `keepBreaks` option is replaced with `--beautify keep-breaks` / `{ beautify: 'keep-breaks' }` to ease transition. +* `--keep-line-breaks` / `keepBreaks` option is replaced with `--format keep-breaks` / `{ format: 'keep-breaks' }` to ease transition. Please note this list is not final. You are more than welcome to comment these changes in [4.0 release discussion](https://github.com/jakubpawlowicz/clean-css/issues/842) thread. @@ -68,9 +68,9 @@ Options: -h, --help output usage information -v, --version output the version number - -b, --beautify [options] Controls output CSS formatting, see examples below -c, --compatibility [ie7|ie8] Force compatibility mode (see Readme for advanced examples) -d, --debug Shows debug information (minification time & compression efficiency) + -f, --format [options] Controls output formatting, see examples below -o, --output [output-file] Use [output-file] as output instead of STDOUT -O [optimizations] Turn on level optimizations; optionally accepts a list of fine-grained options, defaults to `1`, see examples below --inline [rules] Enables inlining for listed sources (defaults to `local`) @@ -109,12 +109,12 @@ cleancss one.css two.css three.css | gzip -9 -c > merged-minified-and-gzipped.cs Please note there is a difference between passing in a concatenated string and letting clean-css do the job. The former will discard `@import` statements appearing [not at the beginning](https://developer.mozilla.org/en-US/docs/Web/CSS/@import) of the string, while the latter will discard only those appearing not at the beginning of any of the files. Because of this behavior, the latter way (see examples above) is recommended. -Beautify options: +Formatting options: ```bash -cleancss --beautify one.css -cleancss --beautify 'indentBy:1;indentWith:tab' one.css -cleancss --beautify 'breaks:afterBlockBegins=off;spaces:aroundSelectorRelation=off' one.css +cleancss --format one.css +cleancss --format 'indentBy:1;indentWith:tab' one.css +cleancss --format 'breaks:afterBlockBegins=off;spaces:aroundSelectorRelation=off' one.css # `breaks` controls where to insert breaks # `afterAtRule` controls if a line break comes after an at-rule; e.g. `@charset`; defaults to `on` (alias to `true`) # `afterBlockBegins` controls if a line break comes after a block begins; e.g. `@media`; defaults to `on` @@ -197,8 +197,8 @@ CleanCSS constructor accepts a hash as a parameter, i.e., `new CleanCSS(options)` with the following options available: * `aggressiveMerging` - set to false to disable aggressive merging of properties. -* `beautify` - formats output CSS by using indentation and one rule or property per line. * `compatibility` - enables compatibility mode, see [below for more examples](#how-to-set-a-compatibility-mode) +* `format` - formats output CSS by using indentation and one rule or property per line. * `inline` - whether to inline `@import` rules, can be `['all']`, `['local']` (default), `['remote']`, or a blacklisted domain/path e.g. `['!fonts.googleapis.com']` * `inlineRequest` - an object with [HTTP(S) request options](https://nodejs.org/api/http.html#http_http_request_options_callback) for inlining remote `@import` rules * `inlineTimeout` - an integer denoting a number of milliseconds after which inlining a remote `@import` fails (defaults to 5000 ms) @@ -222,13 +222,13 @@ The output of `minify` method (or the 2nd argument to passed callback) is a hash * `timeSpent` - time spent on optimizations * `efficiency` - a ratio of output size to input size (e.g. 25% if content was reduced from 100 bytes to 75 bytes) -#### How to specify beautify formatting +#### How to specify formatting -The `beautify` option can also accept the following options +The `format` option can accept the following options: ```js new CleanCSS({ - beautify: { + format: { breaks: { // controls where to insert breaks afterAtRule: true, // controls if a line break comes after an at-rule; e.g. `@charset`; defaults to `true` afterBlockBegins: true, // controls if a line break comes after a block begins; e.g. `@media`; defaults to `true` diff --git a/bin/cleancss b/bin/cleancss index 10c4cee1..6308b2d1 100755 --- a/bin/cleancss +++ b/bin/cleancss @@ -13,9 +13,9 @@ var buildVersion = JSON.parse(packageConfig).version; commands .version(buildVersion, '-v, --version') .usage('[options] ') - .option('-b, --beautify [options]', 'Controls output CSS formatting, see examples below') .option('-c, --compatibility [ie7|ie8]', 'Force compatibility mode (see Readme for advanced examples)') .option('-d, --debug', 'Shows debug information (minification time & compression efficiency)') + .option('-f, --format [options]', 'Controls output formatting, see examples below') .option('-o, --output [output-file]', 'Use [output-file] as output instead of STDOUT') .option('-O [optimizations]', 'Turn on level optimizations; optionally accepts a list of fine-grained options, defaults to `1`, see examples below', function (val) { return Math.abs(parseInt(val)); }) .option('--inline [rules]', 'Enables inlining for listed sources (defaults to `local`)') @@ -32,10 +32,10 @@ commands.on('--help', function () { console.log(' %> cleancss -o merged-and-minified.css one.css two.css three.css'); console.log(' %> cleancss one.css two.css three.css | gzip -9 -c > merged-minified-and-gzipped.css.gz'); console.log(''); - console.log(' Beautify options:'); - console.log(' %> cleancss --beautify one.css'); - console.log(' %> cleancss --beautify \'indentBy:1;indentWith:tab\' one.css'); - console.log(' %> cleancss --beautify \'breaks:afterBlockBegins=off;spaces:aroundSelectorRelation=off\' one.css'); + console.log(' Formatting options:'); + console.log(' %> cleancss --format one.css'); + console.log(' %> cleancss --format \'indentBy:1;indentWith:tab\' one.css'); + console.log(' %> cleancss --format \'breaks:afterBlockBegins=off;spaces:aroundSelectorRelation=off\' one.css'); console.log(' %> # `breaks` controls where to insert breaks'); console.log(' %> # `afterAtRule` controls if a line break comes after an at-rule; e.g. `@charset`; defaults to `on` (alias to `true`)'); console.log(' %> # `afterBlockBegins` controls if a line break comes after a block begins; e.g. `@media`; defaults to `on`'); @@ -124,8 +124,8 @@ if (!fromStdin && commands.args.length === 0) { var debugMode = commands.debug; var options = { aggressiveMerging: commands.skipAggressiveMerging ? false : true, - beautify: commands.beautify, compatibility: commands.compatibility, + format: commands.format, inline: commands.inline || 'local', inlineTimeout: commands.inlineTimeout * 1000, level: commands.O0 || commands.O1 || commands.O2 ? diff --git a/lib/clean.js b/lib/clean.js index c04e9090..850f1ddb 100644 --- a/lib/clean.js +++ b/lib/clean.js @@ -8,7 +8,7 @@ var path = require('path'); var url = require('url'); -var beautifyFrom = require('./options/beautify').beautifyFrom; +var formatFrom = require('./options/format').formatFrom; var OptimizationLevel = require('./options/optimization-level').OptimizationLevel; var optimizationLevelFrom = require('./options/optimization-level').optimizationLevelFrom; @@ -32,8 +32,8 @@ var CleanCSS = module.exports = function CleanCSS(options) { this.options = { aggressiveMerging: undefined === options.aggressiveMerging ? true : !!options.aggressiveMerging, - beautify: beautifyFrom(options.beautify), compatibility: compatibility(options.compatibility), + format: formatFrom(options.format), inline: inlineOptionsFrom(options.inline), inlineRequest: options.inlineRequest || {}, inlineTimeout: options.inlineTimeout || DEFAULT_TIMEOUT, diff --git a/lib/optimizer/level-1/optimize.js b/lib/optimizer/level-1/optimize.js index 78ab4a39..989e4430 100644 --- a/lib/optimizer/level-1/optimize.js +++ b/lib/optimizer/level-1/optimize.js @@ -634,7 +634,7 @@ function level1Optimize(tokens, context) { var ie7Hack = options.compatibility.selectors.ie7Hack; var adjacentSpace = options.compatibility.selectors.adjacentSpace; var spaceAfterClosingBrace = options.compatibility.properties.spaceAfterClosingBrace; - var beautify = options.beautify; + var format = options.format; var mayHaveCharset = false; var afterRules = false; @@ -664,7 +664,7 @@ function level1Optimize(tokens, context) { optimizeComment(token, options); break; case Token.RULE: - token[1] = levelOptions.tidySelectors ? tidyRules(token[1], !ie7Hack, adjacentSpace, beautify, context.warnings) : token[1]; + token[1] = levelOptions.tidySelectors ? tidyRules(token[1], !ie7Hack, adjacentSpace, format, context.warnings) : token[1]; token[1] = token[1].length > 1 ? sortSelectors(token[1], levelOptions.selectorsSortingMethod) : token[1]; optimizeBody(token[2], context); afterRules = true; diff --git a/lib/optimizer/level-1/tidy-rules.js b/lib/optimizer/level-1/tidy-rules.js index acfb8289..09ad3418 100644 --- a/lib/optimizer/level-1/tidy-rules.js +++ b/lib/optimizer/level-1/tidy-rules.js @@ -1,4 +1,4 @@ -var Spaces = require('../../options/beautify').Spaces; +var Spaces = require('../../options/format').Spaces; var Marker = require('../../tokenizer/marker'); var formatPosition = require('../../utils/format-position'); @@ -38,7 +38,7 @@ function hasInvalidCharacters(value) { return isInvalid; } -function removeWhitespace(value, beautify) { +function removeWhitespace(value, format) { var stripped = []; var character; var isNewLineNix; @@ -54,7 +54,7 @@ function removeWhitespace(value, beautify) { var roundBracketLevel = 0; var wasRelation = false; var wasWhitespace = false; - var spaceAroundRelation = beautify && beautify.spaces[Spaces.AroundSelectorRelation]; + var spaceAroundRelation = format && format.spaces[Spaces.AroundSelectorRelation]; var i, l; for (i = 0, l = value.length; i < l; i++) { @@ -137,7 +137,7 @@ function removeQuotes(value) { .replace(/="([a-zA-Z][a-zA-Z\d\-_]+)"/g, '=$1'); } -function tidyRules(rules, removeUnsupported, adjacentSpace, beautify, warnings) { +function tidyRules(rules, removeUnsupported, adjacentSpace, format, warnings) { var list = []; var repeated = []; @@ -157,7 +157,7 @@ function tidyRules(rules, removeUnsupported, adjacentSpace, beautify, warnings) continue; } - reduced = removeWhitespace(reduced, beautify); + reduced = removeWhitespace(reduced, format); reduced = removeQuotes(reduced); if (adjacentSpace && reduced.indexOf('nav') > 0) { diff --git a/lib/options/beautify.js b/lib/options/format.js similarity index 98% rename from lib/options/beautify.js rename to lib/options/format.js index 08756c66..1c2c1baf 100644 --- a/lib/options/beautify.js +++ b/lib/options/format.js @@ -68,7 +68,7 @@ function spaces(value) { return spaceOptions; } -function beautifyFrom(source) { +function formatFrom(source) { if (source === undefined || source === false) { return false; } @@ -174,5 +174,5 @@ function mapIndentWith(value) { module.exports = { Breaks: Breaks, Spaces: Spaces, - beautifyFrom: beautifyFrom + formatFrom: formatFrom }; diff --git a/lib/writer/helpers.js b/lib/writer/helpers.js index c586ef3a..7d8622d3 100644 --- a/lib/writer/helpers.js +++ b/lib/writer/helpers.js @@ -1,8 +1,8 @@ var lineBreak = require('os').EOL; var emptyCharacter = ''; -var Breaks = require('../options/beautify').Breaks; -var Spaces = require('../options/beautify').Spaces; +var Breaks = require('../options/format').Breaks; +var Spaces = require('../options/format').Spaces; var Marker = require('../tokenizer/marker'); var Token = require('../tokenizer/token'); @@ -118,17 +118,17 @@ function value(token, context) { } function allowsBreak(context, where) { - return context.beautify && context.beautify.breaks[where]; + return context.format && context.format.breaks[where]; } function allowsSpace(context, where) { - return context.beautify && context.beautify.spaces[where]; + return context.format && context.format.spaces[where]; } function openBrace(context, where, needsPrefixSpace) { - if (context.beautify) { - context.indentBy += context.beautify.indentBy; - context.indentWith = context.beautify.indentWith.repeat(context.indentBy); + if (context.format) { + context.indentBy += context.format.indentBy; + context.indentWith = context.format.indentWith.repeat(context.indentBy); return (needsPrefixSpace && allowsSpace(context, Spaces.BeforeBlockBegins) ? Marker.SPACE : emptyCharacter) + Marker.OPEN_BRACE + (allowsBreak(context, where) ? lineBreak : emptyCharacter) + @@ -139,9 +139,9 @@ function openBrace(context, where, needsPrefixSpace) { } function closeBrace(context, where, beforeBlockEnd, isLast) { - if (context.beautify) { - context.indentBy -= context.beautify.indentBy; - context.indentWith = context.beautify.indentWith.repeat(context.indentBy); + if (context.format) { + context.indentBy -= context.format.indentBy; + context.indentWith = context.format.indentWith.repeat(context.indentBy); return (allowsBreak(context, Breaks.AfterProperty) || beforeBlockEnd && allowsBreak(context, Breaks.BeforeBlockEnds) ? lineBreak : emptyCharacter) + context.indentWith + Marker.CLOSE_BRACE + @@ -152,19 +152,19 @@ function closeBrace(context, where, beforeBlockEnd, isLast) { } function colon(context) { - return context.beautify ? + return context.format ? Marker.COLON + (allowsSpace(context, Spaces.BeforeValue) ? Marker.SPACE : emptyCharacter) : Marker.COLON; } function semicolon(context, where, isLast) { - return context.beautify ? + return context.format ? Marker.SEMICOLON + (isLast || !allowsBreak(context, where) ? emptyCharacter : lineBreak + context.indentWith) : Marker.SEMICOLON; } function comma(context) { - return context.beautify ? + return context.format ? Marker.COMMA + (allowsBreak(context, Breaks.BetweenSelectors) ? lineBreak : emptyCharacter) + context.indentWith : Marker.COMMA; } diff --git a/lib/writer/simple.js b/lib/writer/simple.js index bf3f1c08..a3736c8c 100644 --- a/lib/writer/simple.js +++ b/lib/writer/simple.js @@ -6,7 +6,7 @@ function store(token, serializeContext) { function serializeStyles(tokens, context) { var serializeContext = { - beautify: context.options.beautify, + format: context.options.format, indentBy: 0, indentWith: '', output: [], diff --git a/lib/writer/source-maps.js b/lib/writer/source-maps.js index ea1dfc59..27a75302 100644 --- a/lib/writer/source-maps.js +++ b/lib/writer/source-maps.js @@ -65,8 +65,8 @@ function trackMapping(mapping, serializeContext) { function serializeStylesAndSourceMap(tokens, context) { var serializeContext = { - beautify: context.options.beautify, column: 0, + format: context.options.format, indentBy: 0, indentWith: '', inlineSources: context.options.sourceMapInlineSources, diff --git a/test/batch-test.js b/test/batch-test.js index 10af1ae9..2106bba5 100644 --- a/test/batch-test.js +++ b/test/batch-test.js @@ -47,7 +47,7 @@ function batchContexts() { topic: function (data) { new CleanCSS({ compatibility: isIE7Mode ? 'ie7' : '*', - beautify: 'keep-breaks', + format: 'keep-breaks', level: { 2: { restructureRules: true @@ -63,7 +63,7 @@ function batchContexts() { topic: function (data) { new CleanCSS({ compatibility: isIE7Mode ? 'ie7' : '*', - beautify: 'keep-breaks', + format: 'keep-breaks', level: { 2: { restructureRules: true @@ -79,7 +79,7 @@ function batchContexts() { 'minifying via CLI': { 'topic': function (data) { exec( - '__DIRECT__=1 ./bin/cleancss -b keep-breaks -O2 restructureRules:on ' + (isIE7Mode ? '-c ie7 ' : '') + path.join(dir, filename), + '__DIRECT__=1 ./bin/cleancss --format keep-breaks -O2 restructureRules:on ' + (isIE7Mode ? '-c ie7 ' : '') + path.join(dir, filename), { maxBuffer: 500 * 1024 }, this.callback.bind(null, data) ); diff --git a/test/binary-test.js b/test/binary-test.js index 32a1e143..d89aefcd 100644 --- a/test/binary-test.js +++ b/test/binary-test.js @@ -87,7 +87,7 @@ vows.describe('./bin/cleancss') }) }) .addBatch({ - 'beautify': pipedContext('a{color: #f00}', '--beautify', { + 'format': pipedContext('a{color: #f00}', '--format', { 'outputs right styles': function (error, stdout) { assert.equal(stdout, 'a {\n color: red\n}'); } diff --git a/test/integration-test.js b/test/integration-test.js index 35729554..105064a0 100644 --- a/test/integration-test.js +++ b/test/integration-test.js @@ -298,7 +298,7 @@ vows.describe('integration tests') '@chArSET \'utf-8\';h1{color:red}', 'h1{color:red}' ] - }, { beautify: 'keep-breaks' }) + }, { format: 'keep-breaks' }) ) .addBatch( optimizerContext('line breaks and important comments', { @@ -306,7 +306,7 @@ vows.describe('integration tests') '/*! some comment */' + lineBreak + lineBreak + '@charset \'utf-8\';' + lineBreak + lineBreak + 'a{display:block}', '@charset \'utf-8\';' + lineBreak + 'a{display:block}' ] - }, { beautify: 'keep-breaks', level: { 1: { specialComments: 0 } } }) + }, { format: 'keep-breaks', level: { 1: { specialComments: 0 } } }) ) .addBatch( optimizerContext('selectors', { @@ -2161,7 +2161,7 @@ vows.describe('integration tests') 'a{color:red}p{display:block}', 'a{color:red}' + lineBreak + 'p{display:block}' ] - }, { beautify: 'keep-breaks', level: 1 }) + }, { format: 'keep-breaks', level: 1 }) ) .addBatch( optimizerContext('invalid data tokenization', { @@ -2613,7 +2613,7 @@ vows.describe('integration tests') 'a{display:block;@apply(--rule1);color:red}', 'a {' + lineBreak + ' display: block;' + lineBreak + ' @apply(--rule1);' + lineBreak + ' color: red' + lineBreak + '}' ] - }, { beautify: true }) + }, { format: true }) ) .addBatch( optimizerContext('custom formatting', { @@ -2629,6 +2629,6 @@ vows.describe('integration tests') '@media screen{a{color:red}div{color:#000}}', '@media screen {' + lineBreak + '\ta {' + lineBreak + '\t\tcolor: red' + lineBreak + '\t}\tdiv {' + lineBreak + '\t\tcolor: #000' + lineBreak + '\t}' + lineBreak + '}' ] - }, { beautify: { breaks: { afterRuleEnds: false }, indentWith: 'tab', indentBy: 1 } }) + }, { format: { breaks: { afterRuleEnds: false }, indentWith: 'tab', indentBy: 1 } }) ) .export(module); diff --git a/test/options/beatutify-test.js b/test/options/format-test.js similarity index 76% rename from test/options/beatutify-test.js rename to test/options/format-test.js index f99e5073..4486662e 100644 --- a/test/options/beatutify-test.js +++ b/test/options/format-test.js @@ -2,32 +2,32 @@ var assert = require('assert'); var vows = require('vows'); -var beautifyFrom = require('../../lib/options/beautify').beautifyFrom; +var formatFrom = require('../../lib/options/format').formatFrom; -vows.describe(beautifyFrom) +vows.describe(formatFrom) .addBatch({ 'undefined': { 'topic': function () { - return beautifyFrom(undefined); + return formatFrom(undefined); }, - 'is false': function (beautifyOptions) { - assert.deepEqual(beautifyOptions, false); + 'is false': function (formatOptions) { + assert.deepEqual(formatOptions, false); } }, 'false': { 'topic': function () { - return beautifyFrom(false); + return formatFrom(false); }, - 'is false': function (beautifyOptions) { - assert.deepEqual(beautifyOptions, false); + 'is false': function (formatOptions) { + assert.deepEqual(formatOptions, false); } }, 'true': { 'topic': function () { - return beautifyFrom(true); + return formatFrom(true); }, - 'is default': function (beautifyOptions) { - assert.deepEqual(beautifyOptions, { + 'is default': function (formatOptions) { + assert.deepEqual(formatOptions, { breaks: { afterAtRule: true, afterBlockBegins: true, @@ -51,10 +51,10 @@ vows.describe(beautifyFrom) }, 'hash': { 'topic': function () { - return beautifyFrom({ breaks: { afterProperty: false }, indentBy: 1 }); + return formatFrom({ breaks: { afterProperty: false }, indentBy: 1 }); }, - 'is merged with default': function (beautifyOptions) { - assert.deepEqual(beautifyOptions, { + 'is merged with default': function (formatOptions) { + assert.deepEqual(formatOptions, { breaks: { afterAtRule: true, afterBlockBegins: true, @@ -78,10 +78,10 @@ vows.describe(beautifyFrom) }, 'hash with indentBy as string': { 'topic': function () { - return beautifyFrom({ indentBy: '2' }); + return formatFrom({ indentBy: '2' }); }, - 'is merged with default': function (beautifyOptions) { - assert.deepEqual(beautifyOptions, { + 'is merged with default': function (formatOptions) { + assert.deepEqual(formatOptions, { breaks: { afterAtRule: true, afterBlockBegins: true, @@ -105,10 +105,10 @@ vows.describe(beautifyFrom) }, 'hash with explicit indentWith': { 'topic': function () { - return beautifyFrom({ indentWith: '\t' }); + return formatFrom({ indentWith: '\t' }); }, - 'is merged with default': function (beautifyOptions) { - assert.deepEqual(beautifyOptions, { + 'is merged with default': function (formatOptions) { + assert.deepEqual(formatOptions, { breaks: { afterAtRule: true, afterBlockBegins: true, @@ -132,10 +132,10 @@ vows.describe(beautifyFrom) }, 'hash with implicit indentWith': { 'topic': function () { - return beautifyFrom({ indentWith: 'tab' }); + return formatFrom({ indentWith: 'tab' }); }, - 'is merged with default': function (beautifyOptions) { - assert.deepEqual(beautifyOptions, { + 'is merged with default': function (formatOptions) { + assert.deepEqual(formatOptions, { breaks: { afterAtRule: true, afterBlockBegins: true, @@ -159,10 +159,10 @@ vows.describe(beautifyFrom) }, 'string': { 'topic': function () { - return beautifyFrom('breaks:afterProperty=off;indentBy:3'); + return formatFrom('breaks:afterProperty=off;indentBy:3'); }, - 'is merged with default': function (beautifyOptions) { - assert.deepEqual(beautifyOptions, { + 'is merged with default': function (formatOptions) { + assert.deepEqual(formatOptions, { breaks: { afterAtRule: true, afterBlockBegins: true, @@ -186,10 +186,10 @@ vows.describe(beautifyFrom) }, 'string with indentWith': { 'topic': function () { - return beautifyFrom('indentWith:tab'); + return formatFrom('indentWith:tab'); }, - 'is merged with default': function (beautifyOptions) { - assert.deepEqual(beautifyOptions, { + 'is merged with default': function (formatOptions) { + assert.deepEqual(formatOptions, { breaks: { afterAtRule: true, afterBlockBegins: true, @@ -213,10 +213,10 @@ vows.describe(beautifyFrom) }, 'string keyword': { 'topic': function () { - return beautifyFrom('keep-breaks'); + return formatFrom('keep-breaks'); }, - 'resolves correctly': function (beautifyOptions) { - assert.deepEqual(beautifyOptions, { + 'resolves correctly': function (formatOptions) { + assert.deepEqual(formatOptions, { breaks: { afterAtRule: true, afterBlockBegins: true, diff --git a/test/source-map-test.js b/test/source-map-test.js index 71292630..7c01edd9 100644 --- a/test/source-map-test.js +++ b/test/source-map-test.js @@ -199,7 +199,7 @@ vows.describe('source-map') }, 'with formatting': { 'topic': function () { - return new CleanCSS({ beautify: 'keep-breaks', level: 2, sourceMap: true }).minify('@media screen { a{color:red} p {color:blue} }div{color:pink}'); + return new CleanCSS({ format: 'keep-breaks', level: 2, sourceMap: true }).minify('@media screen { a{color:red} p {color:blue} }div{color:pink}'); }, 'has 10 mappings': function (minified) { assert.lengthOf(minified.sourceMap._mappings._array, 10); -- 2.34.1