Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

Add friendly error message for missing dotfiles #555

Closed
wants to merge 2 commits into from

Conversation

ohanhi
Copy link
Contributor

@ohanhi ohanhi commented Dec 2, 2015

Fixes #544.

This provides much more human-readable error messages for when certain dotfiles (namely .jscsrc or .jshintrc) are missing from the file system.

With the improvement:
screen shot 2015-12-02 at 23 26 38

Previously:
screen shot 2015-12-02 at 23 25 47

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please let us know the company's name.

@ohanhi
Copy link
Contributor Author

ohanhi commented Dec 2, 2015

I signed it!

@googlebot
Copy link

CLAs look good, thanks!

@googlebot googlebot added cla: yes and removed cla: no labels Dec 2, 2015

var checked = 0;
necessaryFiles.forEach(function(file) {
fs.stat(__dirname + '/' + file, function(err, stats) {
Copy link
Contributor

Choose a reason for hiding this comment

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

path.join() here :)

@ohanhi
Copy link
Contributor Author

ohanhi commented Dec 3, 2015

@samccone Is this ok?

var filesMissing = [];

var checked = 0;
necessaryFiles.forEach(function(file) {
Copy link
Contributor

Choose a reason for hiding this comment

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

can we do

necessaryFiles.map(function(v){ return path.join(__dirname, v); })

reduce or filter down

then do the error check?

(I think in this case it is totally ok to use statSync just to keep the complexity low)

@samccone
Copy link
Contributor

samccone commented Dec 4, 2015

@ohanhi just ping me if you have any questions or whatever, or let me know any thoughts

thanks again for this great PR!

@robdodson
Copy link
Contributor

I'd like to offer a dissenting opinion here. The gulpfile for this project is already extremely complicated and due for some house cleaning. I would vote against adding another task to check for missing files. We have a record of the problem and the fix documented in #544.

@samccone
Copy link
Contributor

samccone commented Dec 5, 2015

The flip side is that this maks an error (which several people now have hit) into a human readable easy to debug locally issue as compared to filing an issue on the bug tracker.

For that reason I am 👍 to it. Most people never touch the gulp file, and those that do are applying recipes.. which cause issues for other reasons .. but we have an idea how to fix that set of issues #552

so, +1 to better errors --- the complexity argument is valid however I think the only reason why I see it as an issue are for the reasons stated in 552

@robdodson
Copy link
Contributor

I think this can be improved with a few lines of instructions in the README vs adding code to the project to support it.

// Check the files necessary for linting exist.
// Without this, the 'lint' task can fail with a very non-descriptive message:
// "TypeError: Cannot convert undefined or null to object"
gulp.task('lintfilesExist', function(cb) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of creating a separate task for this, could we move the code inside the lint task itself? @samccone wdyt?

Copy link
Contributor

Choose a reason for hiding this comment

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

I did a variation on this which seems to work ok: https://gist.github.com/robdodson/9219e1b5042eeca14923

I'm not an expert in throwing errors in Gulp but here's what the output looks like:

screen shot 2015-12-06 at 9 27 18 am

Copy link
Contributor

Choose a reason for hiding this comment

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

personally I think a separate task is pretty nice, easier to test... debug ... ect ect

@samccone
Copy link
Contributor

moved to #580

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

Successfully merging this pull request may close these issues.

None yet

4 participants