gulp-scss-lint icon indicating copy to clipboard operation
gulp-scss-lint copied to clipboard

Config file not found when scss-lint is a dependency of another task

Open mattijsbliek opened this issue 9 years ago • 6 comments

If I run this code, it works without any problems:

gulp.task('scss-lint', function() {
    gulp.src(paths.cssSrc + '/**/*.scss')
        .pipe(cache('scsslint'))
        .pipe(scsslint({'config': '.scss-lint.yml'})).on('error', handleError);
});

But if I add this task as a dependency to another task like so:

gulp.task('scss', ['scss-lint'], function() { ... });

I get an error because it can't find my config file.

I'm using scss-lint v0.29 and gulp-scss-lint v0.1.4. My config file is in the same location as my Gulpfile.

mattijsbliek avatar Oct 09 '14 15:10 mattijsbliek

Temporary solution I found out you can work around this by prepending the globally available __dirname variable to your config location like so:

gulp.task('scss-lint', function() {
    gulp.src(paths.cssSrc + '/**/*.scss')
        .pipe(cache('scsslint'))
        .pipe(scsslint({'config': __dirname + '/.scss-lint.yml'})).on('error', handleError);
});

mattijsbliek avatar Oct 10 '14 11:10 mattijsbliek

It's strange, the same code works well for me... Do you run gulp from another directory?

juanfran avatar Oct 10 '14 12:10 juanfran

Sorry for the late reply!

I did some more debugging, and the problem seems to occur when you run scss-lint as a dependency of another task. I can run it fine on it's own, but as soon as I run gulp.task('sass', ['scss-lint'], function() { ... }); it seems to look for .scss-lint.yml in a different directory.

Stack trace:

Error in plugin 'gulp-scss-lint'
Error code 1
Error: Command failed: /Library/Ruby/Gems/2.0.0/gems/scss-lint-0.29.0/lib/scss_lint/config.rb:184:in `initialize': No such file or directory - .scss-lint.yml (Errno::ENOENT)
    from /Library/Ruby/Gems/2.0.0/gems/scss-lint-0.29.0/lib/scss_lint/config.rb:184:in `open'
    from /Library/Ruby/Gems/2.0.0/gems/scss-lint-0.29.0/lib/scss_lint/config.rb:184:in `load_file_contents'
    from /Library/Ruby/Gems/2.0.0/gems/scss-lint-0.29.0/lib/scss_lint/config.rb:65:in `load_options_hash_from_file'
    from /Library/Ruby/Gems/2.0.0/gems/scss-lint-0.29.0/lib/scss_lint/config.rb:24:in `load'
    from /Library/Ruby/Gems/2.0.0/gems/scss-lint-0.29.0/lib/scss_lint/cli.rb:127:in `setup_configuration'
    from /Library/Ruby/Gems/2.0.0/gems/scss-lint-0.29.0/lib/scss_lint/cli.rb:41:in `parse_arguments'
    from /Library/Ruby/Gems/2.0.0/gems/scss-lint-0.29.0/bin/scss-lint:7:in `block in <top (required)>'
    from /Library/Ruby/Gems/2.0.0/gems/scss-lint-0.29.0/bin/scss-lint:6:in `tap'
    from /Library/Ruby/Gems/2.0.0/gems/scss-lint-0.29.0/bin/scss-lint:6:in `<top (required)>'
    from /usr/bin/scss-lint:23:in `load'
    from /usr/bin/scss-lint:23:in `<main>'

mattijsbliek avatar Oct 22 '14 18:10 mattijsbliek

I tried to do the same and it's works well. Could you make some changes in the plugin?

Edit ./node_modules/gulp-scss-lint/index.js in the line 59 add console.log(process.cwd()); console.log(command);

and tell me what it returns.

Thanks!

juanfran avatar Oct 23 '14 15:10 juanfran

It returns scss-lint /Users/username/Sites/sitename/public/css/sass/base.scss [...] --config /.scss-lint.yml --format XML and then errors with the same error as before.

Problem looks to be that it tries to use /.scss-lint.yml instead of .scss-lint.yml

mattijsbliek avatar Dec 11 '14 18:12 mattijsbliek

Sorry but I don't know that it could be happening, the plugin does't modify the options

juanfran avatar Dec 16 '14 18:12 juanfran