Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #703 from theshortcut/master

Properly handle rjs options.dir if used
  • Loading branch information...
commit a63ce3dc1701e0c0fc006a6bca748dc7ff71091c 2 parents 3f81a23 + b576ae1
Addy Osmani addyosmani authored
Showing with 3 additions and 2 deletions.
  1. +3 −2 cli/tasks/rjs.js
5 cli/tasks/rjs.js
View
@@ -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) {
});
});
-};
+};

1 comment on commit a63ce3d

Cheton Wu

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
    }
}
Please sign in to comment.
Something went wrong with that request. Please try again.