Skip to content

Commit b4fe913

Browse files
committed
Merge remote-tracking branch 'origin/warning-format'
2 parents be57c93 + 5e71ef4 commit b4fe913

File tree

4 files changed

+16
-9
lines changed

4 files changed

+16
-9
lines changed

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ all: clean lint test
33
lint:
44
./node_modules/.bin/jshint *.js
55

6-
TESTS = opts source-maps source-maps-file stdout stdin config config-all js-config js-config-all invalid
6+
TESTS = opts source-maps source-maps-file stdout stdin config config-all js-config js-config-all invalid warning
77

88

99
DIFF = diff -q
@@ -69,6 +69,9 @@ test/build/stdin.css: test/in.css
6969
test/build/invalid.css: test/in-force-error.css
7070
./bin/postcss --use ./test/dummy-plugin --dummy-plugin.fail=true -o $@ $< || echo Error is OK here....
7171

72+
test/build/warning.css: test/in-warning.css
73+
./bin/postcss --use ./test/dummy-plugin -o $@ $< && echo Warning is OK here....
74+
7275
test/build/config.css: test/in.css
7376
./bin/postcss -u postcss-url -c test/config.json -o $@ $<
7477
$(DIFF) $@ $(subst build,ref,$@)

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ function processCSS(processor, input, output, fn) {
187187
function doProcess(css, fn) {
188188
function onResult(result) {
189189
if (typeof result.warnings === 'function') {
190-
result.warnings().forEach(console.error);
190+
result.warnings().forEach(function(w) { console.warn(w.toString()); });
191191
}
192192
fn(null, result);
193193
}

test/dummy-plugin.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
module.exports = function(opts) {
1+
var postcss = require('postcss');
2+
3+
module.exports = postcss.plugin('dummy-plugin', function(opts) {
24
opts = opts || {};
35

4-
return function (css) {
6+
return function (css, result) {
57
// throw something so that we can test error messages
68
if (css.nodes[0].selector === 'a') {
79
throw css.nodes[0].error('Dummy error');
810
}
11+
if (css.nodes[0].selector === 'figure') {
12+
result.warn('Dummy warning', { node: css.nodes[0] });
13+
}
914
};
10-
};
11-
12-
module.exports.postcss = function (css) {
13-
return module.exports()(css);
14-
};
15+
});

test/in-warning.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
figure {
2+
display: none;
3+
}

0 commit comments

Comments
 (0)