Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove dependency on grunt-lib-contrib #25

Merged
merged 1 commit into from
Mar 2, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@
"async": "~0.2.10",
"cache-swap": "~0.0.5",
"csslint": "~0.10.0",
"grunt-lib-contrib": "~0.6.1",
"less": "~1.6.1",
"underscore": "~1.6.0"
"underscore": "~1.6.0",
"strip-path": "~0.1.0",
"chalk": "~0.4.0"
},
"devDependencies": {
"grunt": "~0.4.2",
Expand Down
16 changes: 8 additions & 8 deletions src/less-lint-task.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
async = require 'async'
path = require 'path'
crypto = require 'crypto'
stripPath = require 'strip-path'
_ = require 'underscore'
chalk = require 'chalk'

defaultLessOptions =
cleancss: false
Expand All @@ -15,9 +18,6 @@ defaultLessOptions =
syncImport: true

module.exports = (grunt) ->
{stripPath} = require('grunt-lib-contrib').init grunt

_ = grunt.util._

originalPositionFor = (css, less, file, line) ->
cssLines = css.split('\n')
Expand Down Expand Up @@ -72,14 +72,14 @@ module.exports = (grunt) ->

fileErrors = 0

grunt.log.writeln("#{file.yellow} (#{messages.length})")
grunt.log.writeln("#{chalk.yellow(file)} (#{messages.length})")

messages = _.groupBy messages, ({message}) -> message
for ruleMessage, ruleMessages of messages
rule = ruleMessages[0].rule
fullRuleMessage = "#{ruleMessage} "
fullRuleMessage += "#{rule.desc} " if rule.desc and rule.desc isnt ruleMessage
grunt.log.writeln(fullRuleMessage + "(#{rule.id})".grey)
grunt.log.writeln(fullRuleMessage + chalk.grey("(#{rule.id})"))

for message in ruleMessages
line = message.line
Expand All @@ -91,16 +91,16 @@ module.exports = (grunt) ->

if lineNumber >= 0
message.line = lineNumber
errorPrefix = "#{stripPath(filePath, process.cwd())} #{lineNumber + 1}:".yellow
errorPrefix = chalk.yellow("#{stripPath(filePath, process.cwd())} #{lineNumber + 1}:")

grunt.log.error("#{errorPrefix} #{less.split('\n')[lineNumber].trim()}")
else
cssLine = css.split('\n')[line]
if cssLine?
errorPrefix = "#{line + 1}:".yellow
errorPrefix = chalk.yellow("#{line + 1}:")
grunt.log.error("#{errorPrefix} #{cssLine.trim()}")

grunt.log.writeln("Failed to find map CSS line #{line + 1} to a LESS line.".yellow)
grunt.log.writeln(chalk.yellow("Failed to find map CSS line #{line + 1} to a LESS line."))

fileErrors

Expand Down
5 changes: 3 additions & 2 deletions src/lib/less-file.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ crypto = require 'crypto'
LessParser = require './less-parser'
CssLinter = require './css-linter'
{LintCache} = require './lint-cache'
chalk = require 'chalk'

# Base Class representing a file to be linted
class LessFile
Expand All @@ -11,11 +12,11 @@ class LessFile
lint: (callback) ->
# Parse the LESS into CSS
@getCss (err, css) =>
return callback(new Error("Error parsing #{@filePath.yellow}: #{err.message}")) if err
return callback(new Error("Error parsing #{chalk.yellow(@filePath)}: #{err.message}")) if err

# Lint the css
@lintCss css, (err, result) =>
return callback(new Error("Error linting #{@filePath.yellow}: #{err.message}")) if err
return callback(new Error("Error linting #{chalk.yellow(@filePath)}: #{err.message}")) if err

callback null, result, @getContents(), css

Expand Down