Skip to content

Commit e51918a

Browse files
committed
Switch to picocolors
1 parent e969b79 commit e51918a

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

package-lock.json

+4-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
],
2727
"dependencies": {
2828
"diff": "^5.0.0",
29-
"maxmin": "^3.0.0"
29+
"maxmin": "^3.0.0",
30+
"picocolors": "^1.0.0"
3031
},
3132
"devDependencies": {
3233
"@lodder/time-grunt": "^4.0.0",

tasks/postcss.js

+8-7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const path = require('path')
44
const postcss = require('postcss')
55
const diff = require('diff')
66
const maxmin = require('maxmin')
7+
const picocolors = require('picocolors')
78

89
module.exports = (grunt) => {
910
let options
@@ -149,7 +150,7 @@ module.exports = (grunt) => {
149150
for (const f of this.files) {
150151
const src = f.src.filter((filepath) => {
151152
if (!grunt.file.exists(filepath)) {
152-
grunt.log.error('Source file \x1b[33m%s\x1b[0m not found.', filepath)
153+
grunt.log.error(`Source file ${picocolors.cyan(filepath)} not found.`)
153154

154155
return false
155156
}
@@ -158,7 +159,7 @@ module.exports = (grunt) => {
158159
})
159160

160161
if (src.length === 0) {
161-
grunt.log.error('\x1b[31mNo source files were found.\x1b[0m')
162+
grunt.log.error(picocolors.red('No source files were found.'))
162163

163164
done()
164165
continue
@@ -175,13 +176,13 @@ module.exports = (grunt) => {
175176
tally.issues += warnings.length
176177

177178
for (const msg of warnings) {
178-
grunt.log.error('\x1b[31m%s\x1b[0m', msg.toString())
179+
grunt.log.error(picocolors.red(msg.toString()))
179180
}
180181

181182
if (options.writeDest) {
182183
tally.sizeAfter += result.css.length
183184
grunt.file.write(dest, result.css)
184-
grunt.log.ok('File \x1b[36m%s\x1b[0m created. \x1b[36m%s\x1b[0m', dest, maxmin(input.length, result.css.length))
185+
grunt.log.ok(`File ${picocolors.cyan(dest)} created. ${picocolors.green(maxmin(input.length, result.css.length))}`)
185186
}
186187

187188
tally.sheets += 1
@@ -194,7 +195,7 @@ module.exports = (grunt) => {
194195
}
195196

196197
grunt.file.write(mapDest, result.map.toString())
197-
grunt.log.ok('File \x1b[36m%s\x1b[0m created (source map).', `${dest}.map`)
198+
grunt.log.ok(`File ${picocolors.cyan(`${dest}.map`)} created (source map).`)
198199

199200
tally.maps += 1
200201
}
@@ -203,7 +204,7 @@ module.exports = (grunt) => {
203204
const diffPath = typeof options.diff === 'string' ? options.diff : `${dest}.diff`
204205

205206
grunt.file.write(diffPath, diff.createPatch(dest, input, result.css))
206-
grunt.log.ok('File \x1b[36m%s\x1b[0m created (diff).', diffPath)
207+
grunt.log.ok(`File ${picocolors.cyan(diffPath)} created (diff).`)
207208

208209
tally.diffs += 1
209210
}
@@ -215,7 +216,7 @@ module.exports = (grunt) => {
215216
if (tally.sheets) {
216217
if (options.writeDest) {
217218
const size = maxmin(tally.sizeBefore, tally.sizeAfter)
218-
grunt.log.ok(`${tally.sheets} processed ${grunt.util.pluralize(tally.sheets, 'stylesheet/stylesheets')} created. \x1b[36m%s\x1b[0m`, size)
219+
grunt.log.ok(`${tally.sheets} processed ${grunt.util.pluralize(tally.sheets, 'stylesheet/stylesheets')} created. ${picocolors.green(size)}`)
219220
} else {
220221
grunt.log.write(`${tally.sheets} ${grunt.util.pluralize(tally.sheets, 'stylesheet/stylesheets')} processed, no files written.`)
221222
}

0 commit comments

Comments
 (0)