Open dlmiles opened 9 years ago
Ok I fixed the problem by editing grunt-gapreload\tasks\gapreload.js around line 11 and changed it to read:
return { cmd: cmd, cwd: config('cwd') /*|| 'cordova'*/ };
Note the comment out part concerning the 'cordova' subdirectory. Maybe this should only be used if the subdirectory actually exists. Then it would be backward compatible too and compatible with current project layouts.
Nesting the app code in a cordova subdirectory is a personal preference, that's why it's where the task tries to find stuff by default. As you can see on the line you edited, you can configure cwd
to match your project architecture. So, what you need to do is configure grunt-gapreload
as described here, using something like '.'
as the tasks.gapreload.options.cwd
value.
It would be useful if the defaults followed standard project conventions, and those with non-standard personal preferences would configure accordingly.
The problem is, it does not even check the directory exists or not and the error message is cryptic as to the real problem (a non-standard default layout this plugin has configured as a default).
At least a search for the error message (to this issue) will save many people several hours of working out the root cause of the error. :)
Next release will change this default behavior to match common practices.
Instead of: return { cmd: cmd, cwd: config('cwd') /|| 'cordova'/ }; You could do: return { cmd: cmd, cwd: grunt.config('watch.gapreload.options.cwd') || 'cordova' }; Then it actually pulls from the "cwd" option..
Actually, gapreload is how the watch subtask has to be named but this probably isn't where you should store the cwd
setting because cwd
in this case means Cordova Working Directory (where the cordova
commands will work). So cwd
, like any other GapReload option, is retrieved from tasks.gapreload.options, not tasks.watch.gapreload.options. Do you think the second one would be more natural?
Sorry about the delay.. Yeah, I was kinda thinking putting everything in one category would be easier for newbies.. And I kinda made that mistake naturally at first (due to how the wiki was written).
Well, English isn't my native language. Feedback like yours is really important in this case, so that I know how to improve the documentation. But you also can submit a pull request that I'd be more than happy to merge :smile:.
This is on windows. The current layout of the project following current cordova defaults, there is no "cordova" sub-directory and the "cordova" NodeJS project is installed globally
npm install -g cordova
and thecordova
command works from %PATH%.However it looks like
gapreload-add
attempts to runcordova plugin add pro.fing.cordova.gapreload
but fails withFailed with: Error: spawn NOENT
.But the
cordova
command works from the command line ok.Maybe http://gruntjs.com/api/grunt.util and the API grunt.util.spawn(options, doneFunction) will execute correctly on all platforms ?