Skip to content

Commit e70b913

Browse files
committed
Pretty-print plugin warnings
1 parent a9ec9eb commit e70b913

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

index.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const chokidar = require('chokidar')
1111

1212
const postcss = require('postcss')
1313
const postcssrc = require('postcss-load-config')
14+
const reporter = require('postcss-reporter/lib/formatter')()
1415

1516
const logo = `
1617
/|\\
@@ -224,11 +225,6 @@ function css (css, file) {
224225
return postcss(config.plugins)
225226
.process(css, options)
226227
.then((result) => {
227-
if (result.messages) {
228-
result.warnings()
229-
.forEach((warning) => chalk.bold.yellow(`${warning}`))
230-
}
231-
232228
const tasks = []
233229

234230
if (options.to) {
@@ -253,7 +249,10 @@ function css (css, file) {
253249
spinner.text = chalk.bold.green(
254250
`Finished ${file} (${Math.round(process.hrtime(time)[1] / 1e6)}ms)`
255251
)
256-
spinner.succeed()
252+
if (result.warnings().length) {
253+
spinner.fail()
254+
console.warn(reporter(result))
255+
} else spinner.succeed()
257256

258257
return result
259258
})

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"ora": "^1.1.0",
2222
"postcss": "^5.2.11",
2323
"postcss-load-config": "^1.1.0",
24+
"postcss-reporter": "^3.0.0",
2425
"yargs": "^6.6.0"
2526
},
2627
"devDependencies": {

0 commit comments

Comments
 (0)