postcss-log-warnings
Advanced tools
Comparing version 0.2.0 to 0.2.1
# Changelog | ||
## v0.2.1 | ||
- Remove async. | ||
## v0.2.0 | ||
@@ -4,0 +7,0 @@ - Change the print format slightly. |
16
index.js
@@ -12,11 +12,11 @@ 'use strict'; | ||
if (options.throwError) { | ||
exitCode = 1; | ||
} | ||
return function(css, result) { | ||
var p = new Promise(function(resolve) { | ||
processResult(result, resolve, options); | ||
}); | ||
p.then(function(r) { | ||
if (r) console.log(r); | ||
if (options.throwError) exitCode = 1; | ||
}); | ||
return p; | ||
var warningLog = processResult(result, options); | ||
if (warningLog) { | ||
console.log(warningLog); | ||
} | ||
}; | ||
@@ -23,0 +23,0 @@ }); |
@@ -6,3 +6,3 @@ 'use strict'; | ||
module.exports = function(postcssResult, cb, options) { | ||
module.exports = function(postcssResult, options) { | ||
options = options || {}; | ||
@@ -13,6 +13,3 @@ options.plugins = options.plugins || []; | ||
if (!warnings.length) { | ||
cb(); | ||
return; | ||
} | ||
if (!warnings.length) return undefined; | ||
@@ -36,3 +33,3 @@ var output = '\n# postcss-log-warnings\n\n'; | ||
cb(output); | ||
return output; | ||
@@ -39,0 +36,0 @@ function shouldLog(warning) { |
{ | ||
"name": "postcss-log-warnings", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "Log PostCSS warnings in the console", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -45,7 +45,7 @@ # postcss-log-warnings [![Build Status](https://travis-ci.org/davidtheclark/postcss-log-warnings.svg?branch=master)](https://travis-ci.org/davidtheclark/postcss-log-warnings) | ||
- **keepWarnings** (boolean, default = false) | ||
- **keepWarnings** (boolean, default = `false`) | ||
If true, the plugin will *not* clear the warnings after it logs them (by default, it will clear them). Other plugins will then have access to these warnings and might re-print them. | ||
- **plugins** (array of strings, default = []) | ||
- **plugins** (array of strings, default = `[]`) | ||
@@ -52,0 +52,0 @@ If empty, the plugin will log every warning, regardless of which plugin registered it. |
@@ -54,13 +54,20 @@ 'use strict'; | ||
test('processResult with simple mock', function(t) { | ||
t.plan(2); | ||
processResult(_.cloneDeep(mockSimpleResult), function(r) { | ||
t.equal(chalk.stripColor(r), simpleOutput, 'basic'); | ||
}); | ||
processResult(_.cloneDeep(mockSimpleResult), function(r) { | ||
t.equal(chalk.stripColor(r), simpleOutputNoBar, 'excluding bar'); | ||
}, { plugins: ['foo', 'baz']}); | ||
t.equal( | ||
chalk.stripColor(processResult(_.cloneDeep(mockSimpleResult))), | ||
simpleOutput, | ||
'basic' | ||
); | ||
t.equal( | ||
chalk.stripColor( | ||
processResult(_.cloneDeep(mockSimpleResult), { plugins: ['foo', 'baz']}) | ||
), | ||
simpleOutputNoBar, | ||
'excluding bar' | ||
); | ||
t.end(); | ||
}); | ||
test('clearing warnings from result.messages', function(t) { | ||
t.plan(3); | ||
var resultA = _.cloneDeep(mockSimpleResult); | ||
@@ -70,9 +77,13 @@ var resultB = _.cloneDeep(mockSimpleResult); | ||
t.equal(resultA.warnings().length, 3, 'initial length accurate'); | ||
processResult(resultA, function() { | ||
t.equal(resultA.warnings().length, 0, 'warnings are cleared'); | ||
}); | ||
processResult(resultB, function() { | ||
t.deepEqual(mockSimpleResult.messages, resultB.messages, | ||
processResult(resultA); | ||
t.equal(resultA.warnings().length, 0, 'warnings are cleared'); | ||
processResult(resultB, { keepWarnings: true }); | ||
t.deepEqual(mockSimpleResult.messages, resultB.messages, | ||
'keepWarnings option preserves messages exactly'); | ||
}, { keepWarnings: true }); | ||
t.end(); | ||
}); | ||
@@ -136,9 +147,15 @@ | ||
test('processResult with complex mock', function(t) { | ||
t.plan(2); | ||
processResult(_.cloneDeep(mockComplexResult), function(r) { | ||
t.equal(chalk.stripColor(r), complexOutput, 'basic'); | ||
}); | ||
processResult(_.cloneDeep(mockComplexResult), function(r) { | ||
t.equal(chalk.stripColor(r), complexOutputNoBar, 'excluding bar'); | ||
}, { plugins: ['foo']}); | ||
t.equal( | ||
chalk.stripColor(processResult(_.cloneDeep(mockComplexResult))), | ||
complexOutput, | ||
'basic' | ||
); | ||
t.equal( | ||
chalk.stripColor(processResult(_.cloneDeep(mockComplexResult), { plugins: ['foo'] })), | ||
complexOutputNoBar, | ||
'excluding bar' | ||
); | ||
t.end(); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
249
35155