juanfran / gulp-scss-lint

Gulp plugin to lint scss files with `scss-lint`
113 stars 33 forks source link

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

Open mattijsbliek opened 10 years ago

mattijsbliek commented 10 years ago

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 commented 10 years ago

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);
});
juanfran commented 10 years ago

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

mattijsbliek commented 10 years ago

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>'
juanfran commented 10 years ago

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!

mattijsbliek commented 9 years ago

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

juanfran commented 9 years ago

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