Skip to content

Instantly share code, notes, and snippets.

@mikeerickson
Last active November 17, 2022 23:38
Show Gist options
  • Save mikeerickson/fcdcf33f89f57c3e0cecba574e1126bb to your computer and use it in GitHub Desktop.
Save mikeerickson/fcdcf33f89f57c3e0cecba574e1126bb to your computer and use it in GitHub Desktop.
script to execute linter and use pretty output
#!/usr/bin/env node
const execa = require('execa');
const msg = require('@codedungeon/messenger');
const findMatches = (str = '', findStr = '') => {
const re = new RegExp(findStr, 'g');
return str.match(re);
};
execa('npx', ['eslint', '.'], { env: { FORCE_COLOR: 'true' } })
.then((data) => {
if (data.stdout.length === 0) {
console.log('');
msg.success('No linting errors found', 'SUCCESS');
} else {
console.log(data.stdout);
}
})
.catch((data) => {
console.log(data.stdout);
// msg.error('An error occurred executing linter', 'ERROR');
console.log('');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment