sasstools / gulp-sass-lint

Gulp plugin for Sass Lint
MIT License
115 stars 43 forks source link

Multiple root elements in logfile #71

Open categoryshell opened 7 years ago

categoryshell commented 7 years ago

Hello,

When i want to write the results to a logfile (in this case i've tested json and junit output), multiple root elements a written to the file, which causes the file to be json/xml invalid.

In case of the junit output, a lot of information is missing anyway. jUnit export should include all files, including all failed and succeeded tests. As far as i can see, only failed tests are included. When using this in Bamboo, the number of performed tests won't match the real number of performed test. And when a bug is fixed, the test won't change from error to succes but it simply disappears.

Am i doing something wrong?

The task i'm running is:

gulp.task('ci-scssLint', function () {
    var file = fs.createWriteStream('../log/sassLint.json');
    var stream = gulp.src('../../app/design/frontend/**/*.scss')
        .pipe(sassLint({
            options: {
                configFile: 'sass-lint.yml',
                formatter: 'json'
            }
        }))
        .pipe(sassLint.format(file));
    stream.on('finish', function() {
        file.end();
    });
    return stream;
});
tuckerjt07 commented 7 years ago

I'm having the exact same issue.

I was also having the same issue with eslint when creating the stream as a variable. I was able to fix it by creating the stream inline in its format function but that is not an option with this library to my understanding.

I haven't debugged it but from looking at the underlying code I'm almost certain that each file is being passed off to the formatter separately instead of concatenating them into a collection and passing them off as a single entity.

tuckerjt07 commented 7 years ago

After playing around with some potential workarounds I came up with this solution using the gulp-shell package (npm install --save-dev gulp-shell).

gulp.task('lint:test', shell.task(['sass-lint -c sass-lint.yaml -v']));

I noticed that the cli version was working just not the gulp so I am using the shell package to pass through to the command line from gulp. The -v is important or it will not write the file from looking at the sass-lint issues. My output files, source, and formatters are contained in my yaml but can be added with the -f for formatter and -o out/put/path immediately after my yaml file in the above command. The source can be wildcarded and goes between yaml and -v.

sass-lint -f json -o path/to/file src/*/.scss -v