From b4201f716b59e9ec75e7a5485e1b395c0ea96e93 Mon Sep 17 00:00:00 2001 From: jnunez Date: Thu, 7 Jul 2016 13:36:55 +0200 Subject: [PATCH 1/2] Fixes #46 settings, #27 outputFIle --- README.md | 25 +++++++++++++++++++++++-- index.js | 14 +++++++++----- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 7b5e2fd..f2e1e79 100644 --- a/README.md +++ b/README.md @@ -132,9 +132,30 @@ gulp.task('default', function () { ``` --- -### sassLint.format() +### sassLint.format(writable) -Formats the results dependent on your config file or the options you provided to the sassLint task above. The default format is `stylish` but you can choose any of the others that SassLint provides, see the [docs](https://github.com/sasstools/sass-lint/blob/master/docs/options/formatter.md). You can also choose to output to a file from within the options you provide or your config file. See the [output-file docs](https://github.com/sasstools/sass-lint/blob/master/docs/options/output-file.md) +Formats the results dependent on your config file or the options you provided to the sassLint task above. The default format is `stylish` but you can choose any of the others that SassLint provides, see the [docs](https://github.com/sasstools/sass-lint/blob/master/docs/options/formatter.md). + +You can also choose to output to a file from within the options you provide or your config file. See the [output-file docs](https://github.com/sasstools/sass-lint/blob/master/docs/options/output-file.md) + +```javascript +gulp.task('lint_sass_jenkins', function () { + var file = fs.createWriteStream('reports/lint_sass.xml'); + var stream = gulp.src('public/sass/**/*.scss') + .pipe(sassLint({ + options: { + configFile: '.sass-lint.yml', + formatter: 'checkstyle', + 'outout-file': 'reports/lint_sass.xml' + } + })) + .pipe(sassLint.format(file)); + stream.on('finish', function() { + file.end(); + }); + return stream; +}); +``` --- diff --git a/index.js b/index.js index 3747993..64de5da 100644 --- a/index.js +++ b/index.js @@ -36,8 +36,6 @@ var sassLint = function (options) { return cb(); } - // load our config from sassLint and the user provided options if available - config = lint.getConfig(userOptions, configFile); // save the config file within the file object for access when this file is piped around file.userOptions = userOptions; file.configFile = configFile; @@ -60,7 +58,7 @@ var sassLint = function (options) { return compile; } -sassLint.format = function () { +sassLint.format = function (writable) { var compile = through.obj(function (file, encoding, cb) { if (file.isNull()) { return cb(); @@ -70,7 +68,13 @@ sassLint.format = function () { return cb(); } - lint.outputResults(file.sassLint, file.sassConfig); + if (writable) { + var result = lint.format(file.sassLint, file.userOptions); + writable.write(result); + } + else { + lint.outputResults(file.sassLint, file.sassConfig); + } this.push(file); cb(); @@ -113,4 +117,4 @@ sassLint.failOnError = function () { return compile; } -module.exports = sassLint; +module.exports = sassLint; \ No newline at end of file From 4ba1f7280384283cbe994abaa2d8ffcd11d5a553 Mon Sep 17 00:00:00 2001 From: JoniJnm Date: Wed, 20 Jul 2016 22:06:47 +0200 Subject: [PATCH 2/2] Fixes #46 settings, #27 outputFIle --- README.md | 3 +-- index.js | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f2e1e79..02e0b9d 100644 --- a/README.md +++ b/README.md @@ -145,8 +145,7 @@ gulp.task('lint_sass_jenkins', function () { .pipe(sassLint({ options: { configFile: '.sass-lint.yml', - formatter: 'checkstyle', - 'outout-file': 'reports/lint_sass.xml' + formatter: 'checkstyle' } })) .pipe(sassLint.format(file)); diff --git a/index.js b/index.js index 64de5da..f1795f7 100644 --- a/index.js +++ b/index.js @@ -117,4 +117,4 @@ sassLint.failOnError = function () { return compile; } -module.exports = sassLint; \ No newline at end of file +module.exports = sassLint;