grunt-contrib-watch
grunt-contrib-watch copied to clipboard
Cannot find gruntfile if watch is originally run from a different directory.
I have a project that has a npm script that runs from the root directory. The gruntfile.js is in a utils subdirectory.
the command in package.json is "watch": "grunt --gruntfile utils/gruntfile.js watch"
and this runs fine. However when a file is changed, it runs grunt with the same parameters but from the utils folder so it looks for utils/utils/gruntfile.js which doesn't exist and throws the following error.
Reading "gruntfile.js" Gruntfile...ERROR
Fatal error: Unable to find "/git/Orb/utils/utils/gruntfile.js" Gruntfile.
For clarity, package.json is in /git/Orb/package.json
and the gruntfile.js is in /git/Orb/utils/gruntfile.js
I have the same issue
I'm having this issue as well, and it has blocked my development. I'm far from an expert in JavaScript, but I'm going to look into this now, and report back if I can come up with a patch that works for me.
I believe I've found the problem. I created and submitted a PR to address this, though I'd be grateful if someone could review my code and let me know if I've missed any best practices -- this is my first JavaScript code commit!
In the meantime, there exists a workaround, which is to pass an absolute path to the --gruntfile
option.
I'm facing the same issue, path is duplicated when watch triggers grunt.