Skip to content

Commit

Permalink
Merge pull request #18 from zeke/better-output
Browse files Browse the repository at this point in the history
Improve CLI output and use newest version of standard
  • Loading branch information
zeke authored Jun 10, 2017
2 parents a3f990b + 5ba495e commit d2a804b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
37 changes: 18 additions & 19 deletions lib/linter.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
'use strict'

var fs = require('fs')

var async = require('async')
var flatten = require('lodash.flatten')
var standard = require('standard')

var extractCodeBlocks = require('./codeBlockUtils').extractCodeBlocks

var disabledRules = ['no-undef', 'no-unused-vars', 'no-lone-blocks', 'no-labels']
var eslintDisable = '/* eslint-disable ' + disabledRules.join(', ') + ' */\n'

var linter = module.exports = {}
const fs = require('fs')
const async = require('async')
const flatten = require('lodash.flatten')
const standard = require('standard')
const ora = require('ora')
const extractCodeBlocks = require('./codeBlockUtils').extractCodeBlocks
const disabledRules = [
'no-undef',
'no-unused-vars',
'no-unused-expressions',
'no-lone-blocks',
'no-labels'
]
const eslintDisable = '/* eslint-disable ' + disabledRules.join(', ') + ' */\n'
const linter = module.exports = {}

function removeParensWrappingOrphanedObject (block) {
return block.replace(
Expand Down Expand Up @@ -65,18 +68,14 @@ linter.lintText = function (text, standardOptions, done) {

linter.lintFiles = function (files, standardOptions, done) {
var index = 0
const spinner = (files.length > 3) ? ora().start() : null

if (typeof standardOptions === 'function') {
done = standardOptions
standardOptions = {}
}
async.map(files, function (file, callback) {
// Inform the user of progress
if (process.stdout.clearLine && process.stdout.cursorTo) {
process.stdout.clearLine()
process.stdout.cursorTo(0)
}

process.stdout.write('Linting file ' + (index++ + 1) + ' of ' + files.length)
if (spinner) spinner.text('Linting file ' + (index++ + 1) + ' of ' + files.length)

linter.lintText(fs.readFileSync(file, 'utf8'), standardOptions, function (err, errors, outputText) {
if (err) return callback(err)
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"globby": "^6.0.0",
"lodash.flatten": "^4.2.0",
"lodash.range": "^3.1.5",
"standard": "^8.6.0"
"ora": "^1.2.0",
"standard": "^10.0.2"
},
"devDependencies": {
"tap-spec": "^4.1.1",
Expand Down

0 comments on commit d2a804b

Please sign in to comment.