Adds inlining info in debug mode.
authorGoalSmashers <jakub@goalsmashers.com>
Thu, 12 Dec 2013 16:01:23 +0000 (17:01 +0100)
committerGoalSmashers <jakub@goalsmashers.com>
Mon, 6 Jan 2014 18:37:35 +0000 (19:37 +0100)
lib/clean.js
lib/imports/inliner.js
test/binary-test.js

index 3d8ddee..51a563e 100644 (file)
@@ -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;
index 8e26ca8..6384bfb 100644 (file)
@@ -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');
index bbf9617..21688e4 100644 (file)
@@ -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, '');