Skip to content

Commit a3e66fc

Browse files
authored
Merge pull request #85 from MaximDevoir/feat/eslint-with-color
feat: Run ESLint with colors in supported environments
2 parents 7384744 + a4cccef commit a3e66fc

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

bin/github-lint.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
const childProcess = require('child_process')
77
const fs = require('fs')
88
const path = require('path')
9+
const supportsColors = require('supports-color')
10+
11+
const hasBasicColorSupport = supportsColors.stdout.hasBasic && supportsColors.stderr.hasBasic
912

1013
function execFile(command, args) {
1114
return new Promise(resolve => {
@@ -24,6 +27,10 @@ function execFile(command, args) {
2427

2528
let eslintOptions = ['--report-unused-disable-directives', '.']
2629

30+
if (hasBasicColorSupport) {
31+
eslintOptions = eslintOptions.concat(['--color'])
32+
}
33+
2734
const isTypeScriptProject = fs.existsSync('tsconfig.json')
2835

2936
if (isTypeScriptProject) {

package-lock.json

Lines changed: 21 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
"inquirer": ">=6.0.0",
5151
"prettier": ">=1.12.0",
5252
"read-pkg-up": ">=6.0.0",
53+
"supports-color": "^7.1.0",
5354
"svg-element-attributes": ">=1.2.1"
5455
},
5556
"peerDependencies": {

0 commit comments

Comments
 (0)