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

Fix settings and outputFile #49

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
25 changes: 23 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'output-file'

}
}))
.pipe(sassLint.format(file));
stream.on('finish', function() {
file.end();
});
return stream;
});
```

---

Expand Down
14 changes: 9 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -113,4 +117,4 @@ sassLint.failOnError = function () {
return compile;
}

module.exports = sassLint;
module.exports = sassLint;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing newline at end of file.