-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Close GH-154: Move syntax check functionality to an external lib file.
- Loading branch information
1 parent
81197ee
commit a875fe0
Showing
3 changed files
with
59 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
Sindre Sorhus (http://github.com/sindresorhus) | ||
Sindre Sorhus (https://github.com/sindresorhus) | ||
Radko Dinev (https://github.com/radkodinev) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
'use strict'; | ||
|
||
var path = require('path'); | ||
var async = require('async'); | ||
var chalk = require('chalk'); | ||
var spawn = require('win-spawn'); | ||
var grunt = require('grunt'); | ||
|
||
module.exports = function (files, options, cb) { | ||
var failCount = 0; | ||
var filesToCheck = files.filter(function (src) { | ||
return path.basename(src)[0] !== '_' && grunt.file.exists(src); | ||
}); | ||
|
||
async.eachLimit(filesToCheck, options.numCPUs, function (src, next) { | ||
var bin; | ||
var args; | ||
|
||
if (options.bundleExec) { | ||
bin = 'bundle'; | ||
args = ['exec', 'sass', '--check', src]; | ||
} else { | ||
bin = 'sass'; | ||
args = ['--check', src]; | ||
} | ||
|
||
grunt.verbose.writeln('Command: ' + bin + ' ' + args.join(' ')); | ||
|
||
grunt.verbose.writeln('Checking file ' + chalk.cyan(src) + ' syntax.'); | ||
spawn(bin, args, { stdio: 'inherit' }) | ||
.on('error', grunt.warn) | ||
.on('close', function (code) { | ||
if (code > 0) { | ||
failCount++; | ||
grunt.log.error('Checking file ' + chalk.cyan(src) + ' - ' + chalk.red('failed') + '.'); | ||
} else { | ||
grunt.verbose.ok('Checking file ' + chalk.cyan(src) + ' - ' + chalk.green('passed') + '.'); | ||
} | ||
|
||
next(); | ||
}); | ||
}, function () { | ||
if (failCount > 0) { | ||
grunt.warn('Sass check failed for ' + failCount + ' files.'); | ||
} else { | ||
grunt.log.ok('All ' + chalk.cyan(filesToCheck.length) + ' files passed.'); | ||
} | ||
|
||
cb(); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters