From: GoalSmashers Date: Thu, 12 Dec 2013 16:01:23 +0000 (+0100) Subject: Adds inlining info in debug mode. X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=07089d298d6fc7787b866e93fe568f3adae9afa1;p=clean-css.git Adds inlining info in debug mode. --- diff --git a/lib/clean.js b/lib/clean.js index 3d8ddee0..51a563e5 100644 --- a/lib/clean.js +++ b/lib/clean.js @@ -46,7 +46,8 @@ var CleanCSS = module.exports = function CleanCSS(options) { this.stats = {}; this.context = { errors: [], - warnings: [] + warnings: [], + debug: options.debug }; this.errors = this.context.errors; this.warnings = this.context.warnings; diff --git a/lib/imports/inliner.js b/lib/imports/inliner.js index 8e26ca85..6384bfba 100644 --- a/lib/imports/inliner.js +++ b/lib/imports/inliner.js @@ -166,6 +166,9 @@ module.exports = function Inliner(context, options) { return processNext(options); + if (context.debug) + console.error('Inlining remote stylesheet: ' + importedUrl); + options.visited.push(importedUrl); var get = importedUrl.indexOf('http://') === 0 ? @@ -240,6 +243,9 @@ module.exports = function Inliner(context, options) { return processNext(options); + if (context.debug) + console.error('Inlining local stylesheet: ' + fullPath); + options.visited.push(fullPath); var importedData = fs.readFileSync(fullPath, 'utf8'); diff --git a/test/binary-test.js b/test/binary-test.js index bbf9617a..21688e45 100644 --- a/test/binary-test.js +++ b/test/binary-test.js @@ -3,6 +3,7 @@ var assert = require('assert'); var exec = require('child_process').exec; var fs = require('fs'); var http = require('http'); +var path = require('path'); var isWindows = process.platform == 'win32'; var lineBreak = isWindows ? /\r\n/g : /\n/g; @@ -94,6 +95,11 @@ exports.commandsSuite = vows.describe('binary commands').addBatch({ assert.include(stderr, 'Efficiency: 25%'); } }), + 'piped with debug info on inlining': pipedContext('@import url(test/data/imports-min.css);', '-d', { + 'should output inlining info': function(error, stdout, stderr) { + assert.include(stderr, path.join(process.cwd(), 'test/data/imports-min.css')); + }, + }), '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.equal(stdout, '');