Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Properly handle rjs options.dir if used #703

Merged
merged 1 commit into from

5 participants

@theshortcut

In rjs task if options.dir is set it is an absolute path, so using path.join on it and options.baseUrl (also an absolute path) creates a path to non-existant files. This is helpful if building named modules with rjs rather than a single file from usemin.

@addyosmani
Owner

I think this is useful to land. Anyone opposed?

@sindresorhus

lgtm

@netzzwerg

This fix is necessary if you want use named modules in rjs. There is an other pull request with nearly the same problem #711

@addyosmani addyosmani merged commit a63ce3d into yeoman:master

1 check passed

Details default The Travis build passed
@cheton

The original code of using path.join(options.dir, options.baseUrl, m.name + '.js') is the correct usage. The only problem is that both of options.dir and options.baseUrl become absolute path in the rjs.optimize's callback function..

Instead of using var basePath = options.dir || options.baseUrl to determine basePath, please use the following one instead.

grunt.registerHelper('rjs:optimize:js', function(options, cb) {
    var baseUrl = options.baseUrl; // copy options.baseUrl to baseUrl
        :    :    :
    rjs.optimize(options, function(out) {                                                                                                                        
        originals.forEach(function(m) {                                                                                                                            
        var filepath = path.join(options.dir, baseUrl, m.name + '.js'); // it will fix the problem
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 8, 2012
  1. @theshortcut

    handle either options.dir if building with r.js as named modules, or …

    theshortcut authored
    …options.baseUrl if using usemin
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 2 deletions.
  1. +3 −2 cli/tasks/rjs.js
View
5 cli/tasks/rjs.js
@@ -49,7 +49,8 @@ module.exports = function(grunt) {
rjs.optimize(options, function(out) {
grunt.log.writeln(out);
originals.forEach(function(m) {
- var filepath = path.join(options.dir, options.baseUrl, m.name + '.js');
+ var basePath = options.dir || options.baseUrl;
+ var filepath = path.join(basePath, m.name + '.js');
grunt.log
.writeln('rjs optimized module: ' + m.name)
.writeln('>> ' + filepath);
@@ -61,4 +62,4 @@ module.exports = function(grunt) {
});
});
-};
+};
Something went wrong with that request. Please try again.