cloudchen / grunt-template-jasmine-requirejs

RequireJS template for grunt-contrib-jasmine task
111 stars 96 forks source link

Template uses absolute path to load the require.js script #36

Closed louismrose closed 10 years ago

louismrose commented 11 years ago

Hi,

Thanks so much for this template, which has saved me masses of time in getting our app ported over to Grunt!

I've noticed what I think might be a slight issues with the template that generates the Jasmine spec runner. It seems that the generated script tag for require.js always uses the absolute path, rather than the relative path, to the ".grunt" folder. More specifically, line 11 of the template (<script src="<%= temp %>/require.js"></script>) generates <script src=".grunt/grunt-contrib-jasmine/require.js"></script>

Curiously, the script tags that reference other files in the .grunt directory do not have this issue. For my setup they generate the correct relative path, such as <script src="../.grunt/grunt-contrib-jasmine/jasmine.js"></script>

I've taken a quick look at the grunt-contrib-jasmine project, and it seems to provide a function called getRelativeFileList that might be used to solve this issue. I don't feel that I know enough about the internals of either project to provide a patch, but would be happy to do so if somebody could provide a little bit of direction -- is this the right approach? And how would we access the getRelativeFileList function in the template provide by grunt-template-jasmine-requirejs?

Thanks for any help!

Cheers, Louis.

louismrose commented 11 years ago

For anyone else who faces this issue, I should mention that I'm using a symlink task in Grunt to workaround this for now: I add a symlink to the .grunt directory from the directory to which my spec runner is generated.

plumlee commented 11 years ago

I used a grunt-contrib-copy task to work around this. I modified the template file, stored it out of the node_modules directory, and as part of my unit test grunt task I copy it over the original each time. Symlinks weren't an option for me as we're both *nix and Windows.

gilluminate commented 11 years ago

Thanks for the symlink idea.

gilluminate commented 11 years ago

I just submitted pull request https://github.com/cloudchen/grunt-template-jasmine-requirejs/pull/45 which would allow the user to set requireFile as a template option as a path relative to the outfile (_SpecRunner.html)

cloudchen commented 10 years ago

Fixed in v0.1.10