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

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

Open
mattijsbliek opened this issue Oct 9, 2014 · 6 comments

Comments

@mattijsbliek
Copy link

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
Copy link
Author

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
Copy link
Owner

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

@mattijsbliek
Copy link
Author

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
Copy link
Owner

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
Copy link
Author

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
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants