From 2b5e3f3d5244c8f20409d88d747d4c35bc292507 Mon Sep 17 00:00:00 2001 From: Jakub Pawlowicz Date: Sun, 22 Jan 2017 11:31:09 +0100 Subject: [PATCH] See #846 - moves CLI to a separate repository. Moved to https://github.com/jakubpawlowicz/clean-css-cli Why: * At least 85% of top dependants use the API (see ticket) so removing CLI removes `commander` dependency for them; * docs will be easier to follow as they describe API only; * tests run 10x as fast since binary tests took 90% of time; * CLI will be able to provide its own set of features which are not necessarilly provided or requred in API. Drawbacks: * It won't be straightforward to quickly test arbitrary CSS as binary is not available out of the box. --- README.md | 173 +---- bin/cleancss | 242 ------- package.json | 7 +- test/batch-test.js | 13 - test/binary-test.js | 632 ------------------ test/fixtures/129-assets/assets/ui.css | 2 - .../components/bootstrap/css/bootstrap.css | 3 - .../components/bootstrap/images/glyphs.gif | 0 .../components/jquery-ui/css/style.css | 6 - .../components/jquery-ui/images/next.gif | 0 .../components/jquery-ui/images/prev.gif | 0 test/fixtures/imports-min.css | 5 - test/fixtures/imports.css | 4 - test/fixtures/partials/quoted-svg.css | 3 - test/fixtures/sample1-min.css | 4 - test/fixtures/sample1.css | 12 - test/fixtures/unsupported/selectors-ie7.css | 20 - test/fixtures/unsupported/selectors-ie8.css | 17 - 18 files changed, 20 insertions(+), 1123 deletions(-) delete mode 100755 bin/cleancss delete mode 100644 test/binary-test.js delete mode 100644 test/fixtures/129-assets/assets/ui.css delete mode 100644 test/fixtures/129-assets/components/bootstrap/css/bootstrap.css delete mode 100644 test/fixtures/129-assets/components/bootstrap/images/glyphs.gif delete mode 100644 test/fixtures/129-assets/components/jquery-ui/css/style.css delete mode 100644 test/fixtures/129-assets/components/jquery-ui/images/next.gif delete mode 100644 test/fixtures/129-assets/components/jquery-ui/images/prev.gif delete mode 100644 test/fixtures/imports-min.css delete mode 100644 test/fixtures/imports.css delete mode 100644 test/fixtures/partials/quoted-svg.css delete mode 100644 test/fixtures/sample1-min.css delete mode 100644 test/fixtures/sample1.css delete mode 100644 test/fixtures/unsupported/selectors-ie7.css delete mode 100644 test/fixtures/unsupported/selectors-ie8.css diff --git a/README.md b/README.md index 54689864..876e68a1 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ According to [tests](http://goalsmashers.github.io/css-minification-benchmark/) There will be some breaking changes: +* API and CLI interfaces are split, so API stays in this repository while CLI moves to [clean-css-cli](https://github.com/jakubpawlowicz/clean-css-cli); * `root`, `relativeTo`, and `target` options are replaced by a single `rebaseTo` option - this means that rebasing URLs and import inlining is much simpler but may not be (YMMV) as powerful as in 3.x. * `debug` API option is gone as stats are always provided in output object under `stats` property * `roundingPrecision` is disabled by default @@ -59,138 +60,7 @@ Node.js 4.0+ (tested on CentOS, Ubuntu, OS X, and Windows) npm install clean-css ``` -### How to use clean-css CLI? - -Clean-css accepts the following command line arguments (please make sure -you use `` as the very last argument to avoid potential issues): - -``` -Usage: cleancss [options] - -Options: - - -h, --help output usage information - -v, --version output the version number - -c, --compatibility [ie7|ie8] Force compatibility mode (see Readme for advanced examples) - -d, --debug Shows debug information (minification time & compression efficiency) - -f, --format 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`) - --inline-timeout [seconds] Per connection timeout when fetching remote stylesheets (defaults to 5 seconds) - --skip-rebase Disable URLs rebasing - --source-map Enables building input's source map - --source-map-inline-sources Enables inlining sources inside source maps -``` - -#### Examples: - -To minify a **one.css** file into **one-min.css** do: - -``` -cleancss -o one-min.css one.css -``` - -To minify the same **one.css** into the standard output skip the `-o` parameter: - -``` -cleancss one.css -``` - -If you would like to minify a couple of files together, pass more paths in: - -```bash -cleancss -o merged-and-minified.css one.css two.css three.css -``` - -You can also pipe results to other commands, e.g. gzip: - -```bash -cleancss one.css two.css three.css | gzip -9 -c > merged-minified-and-gzipped.css.gz -``` - -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. - -Formatting options: - -```bash -cleancss --format beautify one.css -cleancss --format keep-breaks 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 `off` (alias to `false`) -# `afterBlockBegins` controls if a line break comes after a block begins; e.g. `@media`; defaults to `off` -# `afterBlockEnds` controls if a line break comes after a block ends, defaults to `off` -# `afterComment` controls if a line break comes after a comment; defaults to `off` -# `afterProperty` controls if a line break comes after a property; defaults to `off` -# `afterRuleBegins` controls if a line break comes after a rule begins; defaults to `off` -# `afterRuleEnds` controls if a line break comes after a rule ends; defaults to `off` -# `beforeBlockEnds` controls if a line break comes before a block ends; defaults to `off` -# `betweenSelectors` controls if a line break comes between selectors; defaults to `off` -# `indentBy` controls number of characters to indent with; defaults to `0` -# `indentWith` controls a character to indent with, can be `space` or `tab`; defaults to `space` -# `spaces` controls where to insert spaces -# `aroundSelectorRelatioff` controls if spaces come around selector relations; e.g. `div > a`; defaults to `off` -# `beforeBlockBegins` controls if a space comes before a block begins; e.g. `.block {`; defaults to `off` -# `beforeValue` controls if a space comes before a value; e.g. `width: 1rem`; defaults to `off` -# `wrapAt` controls maximum line length; defaults to `off` -``` - -Level 0 optimizations: - -```bash -cleancss -O0 one.css -``` - -Level 1 optimizations (default): - -```bash -cleancss -O1 one.css -cleancss -O1 removeQuotes:off;roundingPrecision:4;specialComments:1 one.css -cleancss -O1 all:off;specialComments:1 one.css -# `cleanupCharsets` controls `@charset` moving to the front of a stylesheet; defaults to `on` -# `normalizeUrls` controls URL normalzation; default to `on` -# `optimizeBackground` controls `background` property optimizatons; defaults to `on` -# `optimizeBorderRadius` controls `border-radius` property optimizatons; defaults to `on` -# `optimizeFilter` controls `filter` property optimizatons; defaults to `on` -# `optimizeFont controls `font` property optimizatons; defaults to `on` -# `optimizeFontWeight` controls `font-weight` property optimizatons; defaults to `on` -# `optimizeOutline` controls `outline` property optimizatons; defaults to `on` -# `removeNegativePaddings` controls removing negative paddings; defaults to `on` -# `removeQuotes` controls removing quotes when unnecessary; defaults to `on` -# `removeWhitespace` controls removing unused whitespace; defaults to `on` -# `replaceMultipleZeros` contols removing redundant zeros; defaults to `on` -# `replaceTimeUnits` controls replacing time units with shorter values; defaults to `on -# `replaceZeroUnits` controls replacing zero values with units; defaults to `on` -# `roundingPrecision` rounds pixel values to `N` decimal places; `off` disables rounding; defaults to `off` -# `selectorsSortingMethod` denotes selector sorting method; can be `natural` or `standard`; defaults to `standard` -# `specialComments` denotes a number of /*! ... */ comments preserved; defaults to `all` -# `tidyAtRules` controls at-rules (e.g. `@charset`, `@import`) optimizing; defaults to `on` -# `tidyBlockScopes` controls block scopes (e.g. `@media`) optimizing; defaults to `on` -# `tidySelectors` controls selectors optimizing; defaults to `on` -``` - -Level 2 optimizations: - -```bash -cleancss -O2 one.css -cleancss -O2 mergeMedia:off;restructureRules:off;mergeSemantically:on;mergeIntoShorthands:off one.css -cleancss -O2 all:off;removeDuplicateRules:on one.css -# `mergeAdjacentRules` controls adjacent rules merging; defaults to `on` -# `mergeIntoShorthands` controls merging properties into shorthands; defaults to `on` -# `mergeMedia` controls `@media` merging; defaults to `on` -# `mergeNonAdjacentRules` controls non-adjacent rule merging; defaults to `on` -# `mergeSemantically` controls semantic merging; defaults to `off` -# `overrideProperties` controls property overriding based on understandability; defaults to `on` -# `reduceNonAdjacentRules` controls non-adjacent rule reducing; defaults to `on` -# `removeDuplicateFontRules` controls duplicate `@font-face` removing; defaults to `on` -# `removeDuplicateMediaBlocks` controls duplicate `@media` removing; defaults to `on` -# `removeDuplicateRules` controls duplicate rules removing; defaults to `on` -# `restructureRules` controls rule restructuring; defaults to `off` -``` - -### How to use clean-css API? +### How to use clean-css? ```js var CleanCSS = require('clean-css'); @@ -431,8 +301,9 @@ Use the `/*!` notation instead of the standard one `/*`: Clean-css will handle it automatically for you in the following cases: -* When using the CLI specify output path via `-o`/`--output` to rebase URLs as relative to the output file -* When using the API use `rebaseTo` to rebase URLs to the given path (same as with CLI) +* when full paths to input files are passed in; +* when pre-read content is passed in via a hash; +* when `rebaseTo` is used with any of above two. ### How to generate source maps? @@ -458,17 +329,7 @@ new CleanCSS({ level: { 1: { roundingPrecision: 'all=3,px=5' } } }).minify(...) which sets all units rounding precision to 3 digits except `px` unit precision of 5 digits. -#### Using CLI - -To generate a source map, use `--source-map` switch, e.g.: - -``` -cleancss --source-map --output styles.min.css styles.css -``` - -Name of the output file is required, so a map file, named by adding `.map` suffix to output file name, can be created (styles.min.css.map in this case). - -#### Using API +#### How to work with source maps? To generate a source map, use `sourceMap: true` option, e.g.: @@ -477,7 +338,6 @@ new CleanCSS({ sourceMap: true, rebaseTo: pathToOutputDirectory }) .minify(source, function (error, minified) { // access minified.sourceMap for SourceMapGenerator object // see https://github.com/mozilla/source-map/#sourcemapgenerator for more details - // see https://github.com/jakubpawlowicz/clean-css/blob/master/bin/cleancss#L114 on how it's used in clean-css' CLI }); ``` @@ -488,7 +348,6 @@ new CleanCSS({ sourceMap: true, rebaseTo: pathToOutputDirectory }) .minify(source, inputSourceMap, function (error, minified) { // access minified.sourceMap to access SourceMapGenerator object // see https://github.com/mozilla/source-map/#sourcemapgenerator for more details - // see https://github.com/jakubpawlowicz/clean-css/blob/master/bin/cleancss#L114 on how it's used in clean-css' CLI }); ``` @@ -509,7 +368,7 @@ new CleanCSS({ sourceMap: true, rebaseTo: pathToOutputDirectory }).minify({ }); ``` -### How to minify multiple files with API? +### How to minify multiple files? #### Passing an array @@ -534,9 +393,7 @@ Important note - any `@import` rules already present in the hash will be automat ### How to set a compatibility mode? -Compatibility settings are controlled by `--compatibility` switch (CLI) and `compatibility` option (library mode). - -In both modes the following values are allowed: +Compatibility settings are controlled by `compatibility` option, where the following values are allowed: * `'ie7'` - Internet Explorer 7 compatibility mode * `'ie8'` - Internet Explorer 8 compatibility mode @@ -573,11 +430,19 @@ with the following options available: * `'[+-]units.vmax'` - turn on / off treating `vmax` as a proper unit * `'[+-]units.vmin'` - turn on / off treating `vmin` as a proper unit -For example, using `--compatibility 'ie8,+units.rem'` will ensure IE8 compatibility while enabling `rem` units so the following style `margin:0px 0rem` can be shortened to `margin:0`, while in pure IE8 mode it can't be. +For example, using `{ compatibility: 'ie8,+units.rem' }` will ensure IE8 compatibility while enabling `rem` units so the following style `margin:0px 0rem` can be shortened to `margin:0`, while in pure IE8 mode it can't be. -To pass a single off (-) switch in CLI please use the following syntax `--compatibility *,-units.rem`. +You can also pass `compatibility` as a hash of options as follows: -In library mode you can also pass `compatibility` as a hash of options. +```js +new CleanCSS({ + compatibility: { + units: { + rem: false + } + } +}); +``` ### What level 2 optimizations are applied? diff --git a/bin/cleancss b/bin/cleancss deleted file mode 100755 index a2b2cc99..00000000 --- a/bin/cleancss +++ /dev/null @@ -1,242 +0,0 @@ -#!/usr/bin/env node - -var fs = require('fs'); -var path = require('path'); -var CleanCSS = require('../index'); - -var commands = require('commander'); - -var packageConfig = fs.readFileSync(path.join(path.dirname(fs.realpathSync(process.argv[1])), '../package.json')); -var buildVersion = JSON.parse(packageConfig).version; - -// Specify commander options to parse command line params correctly -commands - .version(buildVersion, '-v, --version') - .usage('[options] ') - .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 ', '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`)') - .option('--inline-timeout [seconds]', 'Per connection timeout when fetching remote stylesheets (defaults to 5 seconds)', parseFloat) - .option('--skip-rebase', 'Disable URLs rebasing') - .option('--source-map', 'Enables building input\'s source map') - .option('--source-map-inline-sources', 'Enables inlining sources inside source maps'); - -commands.on('--help', function () { - console.log(' Examples:\n'); - console.log(' %> cleancss one.css'); - console.log(' %> cleancss -o one-min.css one.css'); - 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(' Formatting options:'); - console.log(' %> cleancss --format beautify one.css'); - console.log(' %> cleancss --format keep-breaks one.css'); - console.log(' %> cleancss --format \'indentBy:1;indentWith:tab\' one.css'); - console.log(' %> cleancss --format \'breaks:afterBlockBegins=on;spaces:aroundSelectorRelation=on\' 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 `off` (alias to `false`)'); - console.log(' %> # `afterBlockBegins` controls if a line break comes after a block begins; e.g. `@media`; defaults to `off`'); - console.log(' %> # `afterBlockEnds` controls if a line break comes after a block ends, defaults to `off`'); - console.log(' %> # `afterComment` controls if a line break comes after a comment; defaults to `off`'); - console.log(' %> # `afterProperty` controls if a line break comes after a property; defaults to `off`'); - console.log(' %> # `afterRuleBegins` controls if a line break comes after a rule begins; defaults to `off`'); - console.log(' %> # `afterRuleEnds` controls if a line break comes after a rule ends; defaults to `off`'); - console.log(' %> # `beforeBlockEnds` controls if a line break comes before a block ends; defaults to `off`'); - console.log(' %> # `betweenSelectors` controls if a line break comes between selectors; defaults to `off`'); - console.log(' %> # `indentBy` controls number of characters to indent with; defaults to `0`'); - console.log(' %> # `indentWith` controls a character to indent with, can be `space` or `tab`; defaults to `space`'); - console.log(' %> # `spaces` controls where to insert spaces'); - console.log(' %> # `aroundSelectorRelation` controls if spaces come around selector relations; e.g. `div > a`; defaults to `off`'); - console.log(' %> # `beforeBlockBegins` controls if a space comes before a block begins; e.g. `.block {`; defaults to `off`'); - console.log(' %> # `beforeValue` controls if a space comes before a value; e.g. `width: 1rem`; defaults to `off`'); - console.log(' %> # `wrapAt` controls maximum line length; defaults to `off`'); - console.log(''); - console.log(' Level 0 optimizations:'); - console.log(' %> cleancss -O0 one.css'); - console.log(''); - console.log(' Level 1 optimizations:'); - console.log(' %> cleancss -O1 one.css'); - console.log(' %> cleancss -O1 removeQuotes:off;roundingPrecision:4;specialComments:1 one.css'); - console.log(' %> cleancss -O1 all:off;specialComments:1 one.css'); - console.log(' %> # `cleanupCharsets` controls `@charset` moving to the front of a stylesheet; defaults to `on`'); - console.log(' %> # `normalizeUrls` controls URL normalzation; default to `on`'); - console.log(' %> # `optimizeBackground` controls `background` property optimizatons; defaults to `on`'); - console.log(' %> # `optimizeBorderRadius` controls `border-radius` property optimizatons; defaults to `on`'); - console.log(' %> # `optimizeFilter` controls `filter` property optimizatons; defaults to `on`'); - console.log(' %> # `optimizeFont controls `font` property optimizatons; defaults to `on` '); - console.log(' %> # `optimizeFontWeight` controls `font-weight` property optimizatons; defaults to `on`'); - console.log(' %> # `optimizeOutline` controls `outline` property optimizatons; defaults to `on`'); - console.log(' %> # `removeNegativePaddings` controls removing negative paddings; defaults to `on`'); - console.log(' %> # `removeQuotes` controls removing quotes when unnecessary; defaults to `on`'); - console.log(' %> # `removeWhitespace` controls removing unused whitespace; defaults to `on`'); - console.log(' %> # `replaceMultipleZeros` contols removing redundant zeros; defaults to `on`'); - console.log(' %> # `replaceTimeUnits` controls replacing time units with shorter values; defaults to `on'); - console.log(' %> # `replaceZeroUnits` controls replacing zero values with units; defaults to `on`'); - console.log(' %> # `roundingPrecision` rounds pixel values to `N` decimal places; `off` disables rounding; defaults to `off`'); - console.log(' %> # `selectorsSortingMethod` denotes selector sorting method; can be `natural` or `standard`; defaults to `standard`'); - console.log(' %> # `specialComments` denotes a number of /*! ... */ comments preserved; defaults to `all`'); - console.log(' %> # `tidyAtRules` controls at-rules (e.g. `@charset`, `@import`) optimizing; defaults to `on`'); - console.log(' %> # `tidyBlockScopes` controls block scopes (e.g. `@media`) optimizing; defaults to `on`'); - console.log(' %> # `tidySelectors` controls selectors optimizing; defaults to `on`'); - console.log(''); - console.log(' Level 2 optimizations:'); - console.log(' %> cleancss -O2 one.css'); - console.log(' %> cleancss -O2 mergeMedia:off;restructureRules:off;mergeSemantically:on;mergeIntoShorthands:off one.css'); - console.log(' %> cleancss -O2 all:off;removeDuplicateRules:on one.css'); - console.log(' %> # `mergeAdjacentRules` controls adjacent rules merging; defaults to `on`'); - console.log(' %> # `mergeIntoShorthands` controls merging properties into shorthands; defaults to `on`'); - console.log(' %> # `mergeMedia` controls `@media` merging; defaults to `on`'); - console.log(' %> # `mergeNonAdjacentRules` controls non-adjacent rule merging; defaults to `on`'); - console.log(' %> # `mergeSemantically` controls semantic merging; defaults to `off`'); - console.log(' %> # `overrideProperties` controls property overriding based on understandability; defaults to `on`'); - console.log(' %> # `reduceNonAdjacentRules` controls non-adjacent rule reducing; defaults to `on`'); - console.log(' %> # `removeDuplicateFontRules` controls duplicate `@font-face` removing; defaults to `on`'); - console.log(' %> # `removeDuplicateMediaBlocks` controls duplicate `@media` removing; defaults to `on`'); - console.log(' %> # `removeDuplicateRules` controls duplicate rules removing; defaults to `on`'); - console.log(' %> # `restructureRules` controls rule restructuring; defaults to `off`'); - - process.exit(); -}); - -commands.parse(process.argv); - -if (commands.rawArgs.indexOf('-O0') > -1) { - commands.O0 = true; -} - -if (commands.rawArgs.indexOf('-O1') > -1) { - commands.O1 = findArgumentTo('-O1', commands.rawArgs, commands.args); -} - -if (commands.rawArgs.indexOf('-O2') > -1) { - commands.O2 = findArgumentTo('-O2', commands.rawArgs, commands.args); -} - -// If no sensible data passed in just print help and exit -var fromStdin = !process.env.__DIRECT__ && !process.stdin.isTTY; -if (!fromStdin && commands.args.length === 0) { - commands.outputHelp(); - return 0; -} - -// Now coerce commands into CleanCSS configuration... -var debugMode = commands.debug; -var options = { - compatibility: commands.compatibility, - format: commands.format, - inline: commands.inline || 'local', - inlineTimeout: commands.inlineTimeout * 1000, - level: commands.O0 || commands.O1 || commands.O2 ? - { '0': commands.O0, '1': commands.O1, '2': commands.O2 } : - undefined, - output: commands.output, - rebase: commands.skipRebase ? false : true, - rebaseTo: ('output' in commands) && commands.output.length > 0 ? path.dirname(path.resolve(commands.output)) : process.cwd(), - sourceMap: commands.sourceMap, - sourceMapInlineSources: commands.sourceMapInlineSources -}; - -if (options.sourceMap && !options.output) { - outputFeedback(['Source maps will not be built because you have not specified an output file.'], true); - options.sourceMap = false; -} - -// ... and do the magic! -if (commands.args.length > 0) { - minify(commands.args); -} else { - var stdin = process.openStdin(); - stdin.setEncoding('utf-8'); - var data = ''; - stdin.on('data', function (chunk) { - data += chunk; - }); - stdin.on('end', function () { - minify(data); - }); -} - -function findArgumentTo(option, rawArgs, args) { - var value = true; - var optionAt = rawArgs.indexOf(option); - var nextOption = rawArgs[optionAt + 1]; - var looksLikePath; - var asArgumentAt; - - if (!nextOption) { - return value; - } - - looksLikePath = nextOption.indexOf('.css') > -1 || - /\//.test(nextOption) || - /\\[^\-]/.test(nextOption) || - /^https?:\/\//.test(nextOption); - asArgumentAt = args.indexOf(nextOption); - - if (!looksLikePath) { - value = nextOption; - } - - if (!looksLikePath && asArgumentAt > -1) { - args.splice(asArgumentAt, 1); - } - - return value; -} - -function minify(data) { - new CleanCSS(options).minify(data, function (errors, minified) { - if (debugMode) { - console.error('Original: %d bytes', minified.stats.originalSize); - console.error('Minified: %d bytes', minified.stats.minifiedSize); - console.error('Efficiency: %d%', ~~(minified.stats.efficiency * 10000) / 100.0); - console.error('Time spent: %dms', minified.stats.timeSpent); - - if (minified.inlinedStylesheets.length > 0) { - console.error('Inlined stylesheets:'); - minified.inlinedStylesheets.forEach(function (uri) { - console.error('- %s', uri); - }); - } - } - - outputFeedback(minified.errors, true); - outputFeedback(minified.warnings); - - if (minified.errors.length > 0) { - process.exit(1); - } - - if (minified.sourceMap) { - var mapFilename = path.basename(options.output) + '.map'; - output(minified.styles + '/*# sourceMappingURL=' + mapFilename + ' */'); - outputMap(minified.sourceMap, mapFilename); - } else { - output(minified.styles); - } - }); -} - -function output(minified) { - if (options.output) { - fs.writeFileSync(options.output, minified, 'utf8'); - } else { - process.stdout.write(minified); - } -} - -function outputMap(sourceMap, mapFilename) { - var mapPath = path.join(path.dirname(options.output), mapFilename); - fs.writeFileSync(mapPath, sourceMap.toString(), 'utf-8'); -} - -function outputFeedback(messages, isError) { - var prefix = isError ? '\x1B[31mERROR\x1B[39m:' : 'WARNING:'; - - messages.forEach(function (message) { - console.error('%s %s', prefix, message); - }); -} diff --git a/package.json b/package.json index c4571802..ccaef816 100644 --- a/package.json +++ b/package.json @@ -16,12 +16,8 @@ "bugs": { "url": "https://github.com/jakubpawlowicz/clean-css/issues" }, - "bin": { - "cleancss": "./bin/cleancss" - }, "main": "index.js", "files": [ - "bin", "lib", "History.md", "index.js", @@ -30,12 +26,11 @@ "scripts": { "browserify": "browserify --standalone CleanCSS index.js | uglifyjs --compress --mangle -o cleancss-browser.js", "bench": "node ./test/bench.js", - "check": "jshint ./bin/cleancss .", + "check": "jshint .", "prepublish": "npm run check", "test": "vows" }, "dependencies": { - "commander": "2.9.x", "source-map": "0.5.x" }, "devDependencies": { diff --git a/test/batch-test.js b/test/batch-test.js index 2106bba5..64976050 100644 --- a/test/batch-test.js +++ b/test/batch-test.js @@ -1,5 +1,4 @@ var assert = require('assert'); -var exec = require('child_process').exec; var fs = require('fs'); var path = require('path'); @@ -75,18 +74,6 @@ function batchContexts() { 'outputs right content': function (data, error, output) { assertEqualLineByLine(data.preoptimized, output.styles); } - }, - 'minifying via CLI': { - 'topic': function (data) { - exec( - '__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) - ); - }, - 'outputs right content': function (data, error, stdout) { - assertEqualLineByLine(data.preoptimized, stdout); - } } }; }); diff --git a/test/binary-test.js b/test/binary-test.js deleted file mode 100644 index c312b2eb..00000000 --- a/test/binary-test.js +++ /dev/null @@ -1,632 +0,0 @@ -var vows = require('vows'); -var assert = require('assert'); -var exec = require('child_process').exec; -var fs = require('fs'); -var http = require('http'); -var httpProxy = require('http-proxy'); -var path = require('path'); -var url = require('url'); -var SourceMapConsumer = require('source-map').SourceMapConsumer; - -var isWindows = process.platform == 'win32'; -var lineBreakRegExp = new RegExp(require('os').EOL, 'g'); - -var binaryContext = function (options, context) { - if (isWindows) - return {}; - - context.topic = function () { - // We add __DIRECT__=1 to force binary into 'non-piped' mode - exec('__DIRECT__=1 ./bin/cleancss ' + options, this.callback); - }; - return context; -}; - -var pipedContext = function (css, options, context) { - if (isWindows) - return {}; - - context.topic = function () { - exec('echo "' + css + '" | ./bin/cleancss ' + options, this.callback); - }; - return context; -}; - -var unixOnlyContext = function (context) { - return isWindows ? {} : context; -}; - -var readFile = function (filename) { - return fs.readFileSync(filename, { encoding: 'utf-8' }).replace(lineBreakRegExp, ''); -}; - -var deleteFile = function (filename) { - if (isWindows) - exec('del /q /f ' + filename); - else - exec('rm ' + filename); -}; - -vows.describe('./bin/cleancss') - .addBatch({ - 'no options': binaryContext('', { - 'should output help': function (stdout) { - assert.match(stdout, /Usage[:]/); - } - }) - }) - .addBatch({ - 'help': binaryContext('-h', { - 'should output help': function (error, stdout) { - assert.match(stdout, /Usage[:]/); - }, - 'should output one file example': function (error, stdout) { - assert.include(stdout, 'cleancss -o one-min.css one.css'); - }, - 'should output multiple files example': function (error, stdout) { - assert.include(stdout, 'cleancss -o merged-and-minified.css one.css two.css three.css'); - }, - 'should output gzipping multiple files example': function (error, stdout) { - assert.include(stdout, 'cleancss one.css two.css three.css | gzip -9 -c > merged-minified-and-gzipped.css.gz'); - } - }) - }) - .addBatch({ - 'version': binaryContext('-v', { - 'should output help': function (error, stdout) { - var version = JSON.parse(fs.readFileSync('./package.json')).version; - assert.equal(stdout, version + '\n'); - } - }) - }) - .addBatch({ - 'stdin': pipedContext('a{color: #f00}', '', { - 'should output data': function (error, stdout) { - assert.equal(stdout, 'a{color:red}'); - } - }) - }) - .addBatch({ - 'format': pipedContext('a{color: #f00}', '--format beautify', { - 'outputs right styles': function (error, stdout) { - assert.equal(stdout, 'a {\n color: red\n}'); - } - }) - }) - .addBatch({ - 'strip all but first comment': pipedContext('/*!1st*//*! 2nd */a{display:block}', '-O1 specialComments:1', { - 'should keep the 2nd comment': function (error, stdout) { - assert.equal(stdout, '/*!1st*/a{display:block}'); - } - }) - }) - .addBatch({ - 'strip all comments': pipedContext('/*!1st*//*! 2nd */a{display:block}', '-O1 specialComments:0', { - 'should keep the 2nd comment': function (error, stdout) { - assert.equal(stdout, 'a{display:block}'); - } - }) - }) - .addBatch({ - 'piped with debug info': pipedContext('a{color: #f00;}', '-d', { - 'should output content to stdout and debug info to stderr': function (error, stdout, stderr) { - assert.equal(stdout, 'a{color:red}'); - assert.notEqual(stderr, ''); - assert.include(stderr, 'Time spent:'); - assert.include(stderr, 'Original: 16 bytes'); - assert.include(stderr, 'Minified: 12 bytes'); - assert.include(stderr, 'Efficiency: 25%'); - } - }) - }) - .addBatch({ - 'piped with debug info on inlining 123': pipedContext('@import url(test/fixtures/imports-min.css);', '-d', { - 'should output inlining info': function (error, stdout, stderr) { - assert.include(stderr, path.join(process.cwd(), 'test/fixtures/imports-min.css')); - } - }) - }) - .addBatch({ - 'piped with correct debug info on inlining': pipedContext('@import url(test/fixtures/imports.css);', '-d', { - 'should output correct info': function (error, stdout, stderr) { - assert.include(stderr, 'Original: 339 bytes'); - assert.include(stderr, 'Minified: 86 bytes'); - assert.include(stderr, 'Efficiency: 74.63%'); - } - }) - }) - .addBatch({ - 'to output file with debug info': pipedContext('a{color: #f00;}', '-d -o debug.css', { - 'should output nothing to stdout and debug info to stderr': function (error, stdout, stderr) { - assert.isEmpty(stdout); - assert.notEqual(stderr, ''); - assert.include(stderr, 'Time spent:'); - assert.include(stderr, 'Original: 16 bytes'); - assert.include(stderr, 'Minified: 12 bytes'); - assert.include(stderr, 'Efficiency: 25%'); - }, - 'should output content to file': function () { - var minimized = readFile('debug.css'); - assert.equal(minimized, 'a{color:red}'); - }, - teardown: function () { - deleteFile('debug.css'); - } - }) - }) - .addBatch({ - 'skip level 2 optimizations': pipedContext('a{color:red}p{color:red}', '-O1', { - 'should do basic optimizations only': function (error, stdout) { - assert.equal(stdout, 'a{color:red}p{color:red}'); - } - }) - }) - .addBatch({ - 'level 1 and 2 optimizations': pipedContext('a{font:"Arial"}a{color:red}', '-O1 all:false,removeQuotes:true -O2 all:false', { - 'should do basic optimizations only': function (error, stdout) { - assert.equal(stdout, 'a{font:Arial}a{color:red}'); - } - }) - }) - .addBatch({ - 'enable restructuring optimizations': pipedContext('div{margin-top:0}.one{margin:0}.two{display:block;margin-top:0}', '-O2 restructureRules:on', { - 'should do basic optimizations only': function (error, stdout) { - assert.equal(stdout, '.two,div{margin-top:0}.one{margin:0}.two{display:block}'); - } - }) - }) - .addBatch({ - 'no relative to path': binaryContext('./fixtures/partials-absolute/base.css', { - 'should not be able to resolve it fully': function (error, stdout, stderr) { - assert.isEmpty(stdout); - assert.notEqual(error, null); - assert.notEqual(stderr, ''); - } - }) - }) - .addBatch({ - 'from source': binaryContext('-O2 ./test/fixtures/reset.css', { - 'should minimize': function (error, stdout) { - var minimized = fs.readFileSync('./test/fixtures/reset-min.css', 'utf-8').replace(lineBreakRegExp, ''); - assert.equal(stdout, minimized); - } - }) - }) - .addBatch({ - 'from multiple sources': binaryContext('./test/fixtures/partials/one.css ./test/fixtures/partials/five.css', { - 'should minimize all': function (error, stdout) { - assert.equal(stdout, '.one{color:red}.five{background:url(data:image/jpeg;base64,/9j/)}'); - } - }) - }) - .addBatch({ - 'to file': binaryContext('-O2 -o ./reset1-min.css ./test/fixtures/reset.css', { - 'should give no output': function (error, stdout) { - assert.isEmpty(stdout); - }, - 'should minimize': function () { - var preminified = readFile('./test/fixtures/reset-min.css'); - var minified = readFile('./reset1-min.css'); - assert.equal(minified, preminified); - }, - teardown: function () { - deleteFile('./reset1-min.css'); - } - }) - }) - .addBatch({ - 'disable @import': binaryContext('--inline none ./test/fixtures/imports.css', { - 'should disable the import processing': function (error, stdout) { - assert.equal(stdout, '@import url(test/fixtures/partials/one.css);@import url(test/fixtures/partials/two.css);.imports{color:#000}'); - } - }) - }) - .addBatch({ - 'disable all @import': pipedContext('@import url(http://127.0.0.1/remote.css);@import url(test/fixtures/partials/one.css);', '--inline none', { - 'keeps original import rules': function (error, stdout) { - assert.equal(stdout, '@import url(http://127.0.0.1/remote.css);@import url(test/fixtures/partials/one.css);'); - } - }), - 'disable remote @import': pipedContext('@import url(http://127.0.0.1/remote.css);@import url(test/fixtures/partials/one.css);', '--inline !remote', { - 'keeps remote import rule': function (error, stdout) { - assert.equal(stdout, '@import url(http://127.0.0.1/remote.css);.one{color:red}'); - } - }), - 'disable remote @import as default': pipedContext('@import url(http://127.0.0.1/remote.css);@import url(test/fixtures/partials/one.css);', '', { - 'keeps remote import rule': function (error, stdout) { - assert.equal(stdout, '@import url(http://127.0.0.1/remote.css);.one{color:red}'); - } - }), - 'disable remote @import by host': pipedContext('@import url(http://127.0.0.1/remote.css);@import url(test/fixtures/partials/one.css);', '--inline !127.0.0.1', { - 'keeps remote import rule': function (error, stdout) { - assert.equal(stdout, '@import url(http://127.0.0.1/remote.css);.one{color:red}'); - } - }) - }) - .addBatch({ - 'relative image paths': { - 'no output': binaryContext('./test/fixtures/partials-relative/base.css', { - 'should leave paths': function (error, stdout) { - assert.equal(stdout, 'a{background:url(test/fixtures/partials/extra/down.gif) 0 0 no-repeat}'); - } - }), - 'output': binaryContext('-o ./base1-min.css ./test/fixtures/partials-relative/base.css', { - 'should rewrite path relative to current path': function () { - var minimized = readFile('./base1-min.css'); - assert.equal(minimized, 'a{background:url(test/fixtures/partials/extra/down.gif) 0 0 no-repeat}'); - }, - teardown: function () { - deleteFile('./base1-min.css'); - } - }), - 'piped with output': pipedContext('a{background:url(test/fixtures/partials/extra/down.gif)}', '-o base3-min.css', { - 'should keep paths as they are': function () { - var minimized = readFile('base3-min.css'); - assert.equal(minimized, 'a{background:url(test/fixtures/partials/extra/down.gif)}'); - }, - teardown: function () { - deleteFile('base3-min.css'); - } - }) - } - }) - .addBatch({ - 'import rebasing': binaryContext('test/fixtures/partials/quoted-svg.css', { - 'should keep quoting intact': function (error, stdout) { - assert.include(stdout, 'div{background:url("data:image'); - assert.include(stdout, 'svg%3E")}'); - } - }) - }) - .addBatch({ - 'complex import and url rebasing': { - 'absolute': binaryContext('./test/fixtures/129-assets/assets/ui.css', { - 'should rebase urls correctly': function (error, stdout) { - assert.include(stdout, 'url(test/fixtures/129-assets/components/bootstrap/images/glyphs.gif)'); - assert.include(stdout, 'url(test/fixtures/129-assets/components/jquery-ui/images/prev.gif)'); - assert.include(stdout, 'url(test/fixtures/129-assets/components/jquery-ui/images/next.gif)'); - } - }), - 'relative': binaryContext('-o test/ui.bundled.css ./test/fixtures/129-assets/assets/ui.css', { - 'should rebase urls correctly': function () { - var minimized = readFile('test/ui.bundled.css'); - assert.include(minimized, 'url(fixtures/129-assets/components/bootstrap/images/glyphs.gif)'); - assert.include(minimized, 'url(fixtures/129-assets/components/jquery-ui/images/prev.gif)'); - assert.include(minimized, 'url(fixtures/129-assets/components/jquery-ui/images/next.gif)'); - }, - teardown: function () { - deleteFile('test/ui.bundled.css'); - } - }) - } - }) - .addBatch({ - 'complex import and skipped url rebasing': { - 'absolute': binaryContext('--skip-rebase ./test/fixtures/129-assets/assets/ui.css', { - 'should rebase urls correctly': function (error, stdout) { - assert.isNull(error); - assert.include(stdout, 'url(../images/glyphs.gif)'); - assert.include(stdout, 'url(../images/prev.gif)'); - assert.include(stdout, 'url(../images/next.gif)'); - } - }) - } - }) - .addBatch({ - 'remote import': { - topic: function () { - this.server = http.createServer(function (req, res) { - res.writeHead(200); - res.end('p{font-size:13px}'); - }).listen(31991, '127.0.0.1'); - - this.callback(null); - }, - 'of a file': binaryContext('http://127.0.0.1:31991/present.css', { - succeeds: function (error, stdout) { - assert.isNull(error); - assert.equal(stdout, 'p{font-size:13px}'); - } - }), - teardown: function () { - this.server.close(); - } - } - }) - .addBatch({ - 'timeout': unixOnlyContext({ - topic: function () { - var self = this; - var source = '@import url(http://localhost:24682/timeout.css);'; - - this.server = http.createServer(function () { - setTimeout(function () {}, 1000); - }); - this.server.listen('24682', function () { - exec('echo "' + source + '" | ./bin/cleancss --inline all --inline-timeout 0.01', self.callback); - }); - }, - 'should raise warning': function (error, stdout, stderr) { - assert.include(stderr, 'Broken @import declaration of "http://localhost:24682/timeout.css" - timeout'); - }, - 'should output empty response': function (error, stdout) { - assert.isEmpty(stdout); - }, - teardown: function () { - this.server.close(); - } - }) - }) - .addBatch({ - 'HTTP proxy': unixOnlyContext({ - topic: function () { - var self = this; - this.proxied = false; - - var proxy = httpProxy.createProxyServer(); - this.proxyServer = http.createServer(function (req, res) { - self.proxied = true; - proxy.web(req, res, { target: 'http://' + url.parse(req.url).host }, function () {}); - }); - this.proxyServer.listen(8081); - - this.server = http.createServer(function (req, res) { - res.writeHead(200); - res.end('a{color:red}'); - }); - this.server.listen(8080); - - exec('echo "@import url(http://127.0.0.1:8080/test.css);" | HTTP_PROXY=http://127.0.0.1:8081 ./bin/cleancss --inline all', this.callback); - }, - 'proxies the connection': function () { - assert.isTrue(this.proxied); - }, - 'gives right output': function (error, stdout) { - assert.equal(stdout, 'a{color:red}'); - }, - teardown: function () { - this.proxyServer.close(); - this.server.close(); - } - }) - }) - .addBatch({ - 'ie7 compatibility': binaryContext('--compatibility ie7 ./test/fixtures/unsupported/selectors-ie7.css', { - 'should not transform source': function (error, stdout) { - assert.equal(stdout, readFile('./test/fixtures/unsupported/selectors-ie7.css')); - } - }) - }) - .addBatch({ - 'ie8 compatibility': binaryContext('--compatibility ie8 ./test/fixtures/unsupported/selectors-ie8.css', { - 'should not transform source': function (error, stdout) { - assert.equal(stdout, readFile('./test/fixtures/unsupported/selectors-ie8.css')); - } - }) - }) - .addBatch({ - 'custom compatibility': pipedContext('a{_color:red}', '--compatibility "+properties.iePrefixHack"', { - 'should not transform source': function (error, stdout) { - assert.equal(stdout, 'a{_color:red}'); - } - }) - }) - .addBatch({ - 'rounding precision': { - 'default': pipedContext('div{width:0.10051px}', '', { - 'should keep 2 decimal places': function (error, stdout) { - assert.equal(stdout, 'div{width:.10051px}'); - } - }), - 'custom': pipedContext('div{width:0.00051px}', '-O1 roundingPrecision:4', { - 'should keep 4 decimal places': function (error, stdout) { - assert.equal(stdout, 'div{width:.0005px}'); - } - }), - 'zero': pipedContext('div{width:1.5051px}', '-O1 roundingPrecision:0', { - 'should keep 0 decimal places': function (error, stdout) { - assert.equal(stdout, 'div{width:2px}'); - } - }), - 'disabled': pipedContext('div{width:0.12345px}', '-O1 roundingPrecision:off', { - 'should keep all decimal places': function (error, stdout) { - assert.equal(stdout, 'div{width:.12345px}'); - } - }), - 'disabled via -1': pipedContext('div{width:0.12345px}', '-O1 roundingPrecision:\\\\-1', { - 'should keep all decimal places': function (error, stdout) { - assert.equal(stdout, 'div{width:.12345px}'); - } - }), - 'fine-grained': pipedContext('div{height:10.515rem;width:12.12345px}', '-O1 roundingPrecision:rem=2,px=1', { - 'should keep all decimal places': function (error, stdout) { - assert.equal(stdout, 'div{height:10.52rem;width:12.1px}'); - } - }) - } - }) - .addBatch({ - 'neighbour merging': { - 'of unmergeable properties': pipedContext('a{display:inline-block;color:red;display:-moz-block}', '-O2', { - 'gets right result': function (error, stdout) { - assert.equal(stdout, 'a{display:inline-block;color:red;display:-moz-block}'); - } - }), - 'of mergeable properties': pipedContext('a{background:red;display:block;background:white}', '-O2', { - 'gets right result': function (error, stdout) { - assert.equal(stdout, 'a{background:#fff;display:block}'); - } - }) - } - }) - .addBatch({ - '@media merging': pipedContext('@media screen{a{color:red}}@media screen{a{display:block}}', '-O2 mergeMedia:off', { - 'gets right result': function (error, stdout) { - assert.equal(stdout, '@media screen{a{color:red}}@media screen{a{display:block}}'); - } - }) - }) - .addBatch({ - 'shorthand merging': { - 'of mergeable properties with overriding off': pipedContext('a{background:url(image.png);background-color:red}', '-O2 overrideProperties:off', { - 'gets right result': function (error, stdout) { - assert.equal(stdout, 'a{background:url(image.png);background-color:red}'); - } - }) - } - }) - .addBatch({ - 'source maps - no target file': binaryContext('--source-map ./test/fixtures/reset.css', { - 'warns about source map not being build': function (error, stdout, stderr) { - assert.include(stderr, 'Source maps will not be built because you have not specified an output file.'); - }, - 'does not include map in stdout': function (error, stdout) { - assert.notInclude(stdout, '/*# sourceMappingURL'); - } - }) - }) - .addBatch({ - 'source maps - output file': binaryContext('--source-map -o ./reset.min.css ./test/fixtures/reset.css', { - 'includes map in minified file': function () { - assert.include(readFile('./reset.min.css'), '/*# sourceMappingURL=reset.min.css.map */'); - }, - 'creates a map file': function () { - assert.isTrue(fs.existsSync('./reset.min.css.map')); - }, - 'includes right content in map file': function () { - var sourceMap = new SourceMapConsumer(readFile('./reset.min.css.map')); - assert.deepEqual( - sourceMap.originalPositionFor({ line: 1, column: 1 }), - { - source: 'test/fixtures/reset.css', - line: 4, - column: 0, - name: null - } - ); - }, - 'teardown': function () { - deleteFile('reset.min.css'); - deleteFile('reset.min.css.map'); - } - }) - }) - .addBatch({ - 'source maps - output file in same folder as input': unixOnlyContext({ - topic: function () { - var self = this; - - exec('cp test/fixtures/reset.css .', function () { - exec('__DIRECT__=1 ./bin/cleancss --source-map -o ./reset.min.css ./reset.css', self.callback); - }); - }, - 'includes right content in map file': function () { - var sourceMap = new SourceMapConsumer(readFile('./reset.min.css.map')); - assert.deepEqual( - sourceMap.originalPositionFor({ line: 1, column: 1 }), - { - source: 'reset.css', - line: 4, - column: 0, - name: null - } - ); - }, - 'teardown': function () { - deleteFile('reset.css'); - deleteFile('reset.min.css'); - deleteFile('reset.min.css.map'); - } - }) - }) - .addBatch({ - 'source maps - output file with existing map': binaryContext('--source-map -o ./styles.min.css ./test/fixtures/source-maps/styles.css', { - 'includes right content in map file': function () { - var sourceMap = new SourceMapConsumer(readFile('./styles.min.css.map')); - assert.deepEqual( - sourceMap.originalPositionFor({ line: 1, column: 1 }), - { - source: 'test/fixtures/source-maps/styles.less', - line: 1, - column: 4, - name: null - } - ); - }, - 'teardown': function () { - deleteFile('styles.min.css'); - deleteFile('styles.min.css.map'); - } - }) - }) - .addBatch({ - 'source maps - output file for existing map in different folder': binaryContext('--source-map -o ./styles-relative.min.css ./test/fixtures/source-maps/relative.css', { - 'includes right content in map file': function () { - var sourceMap = new SourceMapConsumer(readFile('./styles-relative.min.css.map')); - assert.deepEqual( - sourceMap.originalPositionFor({ line: 1, column: 1 }), - { - source: 'test/fixtures/source-maps/sub/styles.less', - line: 2, - column: 2, - name: null - } - ); - }, - 'teardown': function () { - deleteFile('styles-relative.min.css'); - deleteFile('styles-relative.min.css.map'); - } - }) - }) - .addBatch({ - 'source maps - with input source map': binaryContext('--source-map -o ./import.min.css ./test/fixtures/source-maps/import.css', { - 'includes map in minified file': function () { - assert.include(readFile('./import.min.css'), '/*# sourceMappingURL=import.min.css.map */'); - }, - 'includes right content in map file': function () { - var sourceMap = new SourceMapConsumer(readFile('./import.min.css.map')); - var count = 0; - sourceMap.eachMapping(function () { count++; }); - - assert.equal(count, 6); - }, - 'teardown': function () { - deleteFile('import.min.css'); - deleteFile('import.min.css.map'); - } - }) - }) - .addBatch({ - 'source maps - with input source map and source inlining': binaryContext('--source-map --source-map-inline-sources -o ./import-inline.min.css ./test/fixtures/source-maps/import.css', { - 'includes map in minified file': function () { - assert.include(readFile('./import-inline.min.css'), '/*# sourceMappingURL=import-inline.min.css.map */'); - }, - 'includes embedded sources': function () { - var sourceMap = new SourceMapConsumer(readFile('./import-inline.min.css.map')); - var count = 0; - sourceMap.eachMapping(function () { count++; }); - - assert.equal(count, 6); - }, - 'teardown': function () { - deleteFile('import-inline.min.css'); - deleteFile('import-inline.min.css.map'); - } - }) - }) - .addBatch({ - 'semantic merging': { - 'disabled': pipedContext('.a{margin:0}.b{margin:10px;padding:0}.c{margin:0}', '', { - 'should output right data': function (error, stdout) { - assert.equal(stdout, '.a{margin:0}.b{margin:10px;padding:0}.c{margin:0}'); - } - }), - 'enabled': pipedContext('.a{margin:0}.b{margin:10px;padding:0}.c{margin:0}', '-O2 mergeSemantically:on', { - 'should output right data': function (error, stdout) { - assert.equal(stdout, '.a,.c{margin:0}.b{margin:10px;padding:0}'); - } - }) - } - }) - .export(module); diff --git a/test/fixtures/129-assets/assets/ui.css b/test/fixtures/129-assets/assets/ui.css deleted file mode 100644 index 248fcf54..00000000 --- a/test/fixtures/129-assets/assets/ui.css +++ /dev/null @@ -1,2 +0,0 @@ -@import url(../components/bootstrap/css/bootstrap.css); -@import url(../components/jquery-ui/css/style.css); diff --git a/test/fixtures/129-assets/components/bootstrap/css/bootstrap.css b/test/fixtures/129-assets/components/bootstrap/css/bootstrap.css deleted file mode 100644 index 1e57cca3..00000000 --- a/test/fixtures/129-assets/components/bootstrap/css/bootstrap.css +++ /dev/null @@ -1,3 +0,0 @@ -.icon { - background:url(../images/glyphs.gif) 0 0 no-repeat; -} diff --git a/test/fixtures/129-assets/components/bootstrap/images/glyphs.gif b/test/fixtures/129-assets/components/bootstrap/images/glyphs.gif deleted file mode 100644 index e69de29b..00000000 diff --git a/test/fixtures/129-assets/components/jquery-ui/css/style.css b/test/fixtures/129-assets/components/jquery-ui/css/style.css deleted file mode 100644 index d03309bc..00000000 --- a/test/fixtures/129-assets/components/jquery-ui/css/style.css +++ /dev/null @@ -1,6 +0,0 @@ -.prev { - background:url(../images/prev.gif) 0 0 no-repeat; -} -.next { - background:url(../images/next.gif) 0 0 no-repeat; -} diff --git a/test/fixtures/129-assets/components/jquery-ui/images/next.gif b/test/fixtures/129-assets/components/jquery-ui/images/next.gif deleted file mode 100644 index e69de29b..00000000 diff --git a/test/fixtures/129-assets/components/jquery-ui/images/prev.gif b/test/fixtures/129-assets/components/jquery-ui/images/prev.gif deleted file mode 100644 index e69de29b..00000000 diff --git a/test/fixtures/imports-min.css b/test/fixtures/imports-min.css deleted file mode 100644 index 4dcf005c..00000000 --- a/test/fixtures/imports-min.css +++ /dev/null @@ -1,5 +0,0 @@ -.one{color:red} -.three{color:#0f0} -.four{color:#00f} -.two{color:#fff} -.imports{color:#000} \ No newline at end of file diff --git a/test/fixtures/imports.css b/test/fixtures/imports.css deleted file mode 100644 index 41d3f809..00000000 --- a/test/fixtures/imports.css +++ /dev/null @@ -1,4 +0,0 @@ -@import url('./partials/one.css'); -@import url("./partials/two.css"); - -.imports { color: #000; } \ No newline at end of file diff --git a/test/fixtures/partials/quoted-svg.css b/test/fixtures/partials/quoted-svg.css deleted file mode 100644 index 85ac44b1..00000000 --- a/test/fixtures/partials/quoted-svg.css +++ /dev/null @@ -1,3 +0,0 @@ -div { - background: url("data:image/svg+xml;charset=UTF-8,%3Csvg%20xmD%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20xmlns%3Axlink%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink%22%20width%3D%22100%22%20height%3D%22100%22%20viewBox%3D%220%200%20100%20100%22%20overflow%3D%22visible%22%3E%3Cdefs%3E%3Cellipse%20id%3D%22a%22%20cx%3D%2250%22%20cy%3D%2250%22%20rx%3D%2250%22%20ry%3D%2250%22%2F%3E%3C%2Fdefs%3E%3Cuse%20xlink%3Ahref%3D%22%23a%22%20overflow%3D%22visible%22%20fill%3D%22%2300f%22%2F%3E%3CclipPath%20id%3D%22b%22%3E%3Cuse%20xlink%3Ahref%3D%22%23a%22%20overflow%3D%22visible%22%2F%3E%3C%2FclipPath%3E%3Cg%20clip-path%3D%22url(%23b)%22%3E%3Cpath%20d%3D%22M0%20100h50V50H0z%22%20fill%3D%22%230f0%22%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E"); -} diff --git a/test/fixtures/sample1-min.css b/test/fixtures/sample1-min.css deleted file mode 100644 index dd5ca77f..00000000 --- a/test/fixtures/sample1-min.css +++ /dev/null @@ -1,4 +0,0 @@ -.field ::-webkit-input-placeholder{color:#bbb} -.field :-moz-placeholder{color:#bbb} -.field :-ms-input-placeholder{color:#bbb} -.field.enabled ::-webkit-input-placeholder{opacity:0} diff --git a/test/fixtures/sample1.css b/test/fixtures/sample1.css deleted file mode 100644 index 89433498..00000000 --- a/test/fixtures/sample1.css +++ /dev/null @@ -1,12 +0,0 @@ -.field ::-webkit-input-placeholder { - color:#bbb; -} -.field :-moz-placeholder { - color:#bbb; -} -.field :-ms-input-placeholder { - color:#bbb; -} -.field.enabled ::-webkit-input-placeholder { - opacity:0; -} diff --git a/test/fixtures/unsupported/selectors-ie7.css b/test/fixtures/unsupported/selectors-ie7.css deleted file mode 100644 index 3f2fc3ed..00000000 --- a/test/fixtures/unsupported/selectors-ie7.css +++ /dev/null @@ -1,20 +0,0 @@ -p:focus{top:0} -p:before{top:0} -p:after{top:0} -p:root{top:0} -p:nth-of-type(1){top:0} -p:nth-last-of-type(1){top:0} -p:first-of-type{top:0} -p:last-of-type{top:0} -p:only-of-type{top:0} -p:only-child{top:0} -p:last-child{top:0} -p:nth-child(1){top:0} -p:nth-last-child(1){top:0} -p:empty{top:0} -p:target{top:0} -p:checked{top:0} -p::selection{top:0} -input:enabled{top:0} -input:disabled{top:0} -p:not(.x){top:0} diff --git a/test/fixtures/unsupported/selectors-ie8.css b/test/fixtures/unsupported/selectors-ie8.css deleted file mode 100644 index 2d01251e..00000000 --- a/test/fixtures/unsupported/selectors-ie8.css +++ /dev/null @@ -1,17 +0,0 @@ -p:root{top:0} -p:nth-of-type(1){top:0} -p:nth-last-of-type(1){top:0} -p:first-of-type{top:0} -p:last-of-type{top:0} -p:only-of-type{top:0} -p:only-child{top:0} -p:last-child{top:0} -p:nth-child(1){top:0} -p:nth-last-child(1){top:0} -p:empty{top:0} -p:target{top:0} -p:checked{top:0} -p::selection{top:0} -input:enabled{top:0} -input:disabled{top:0} -p:not(.x){top:0} -- 2.34.1