Skip to content

Commit

Permalink
Implement getBaseUrl in a way that can't recurse and is more likely t…
Browse files Browse the repository at this point in the history
…o succeed
  • Loading branch information
lukeapage committed Mar 26, 2015
1 parent 890766c commit dad367d
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/template-jasmine-requirejs.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,15 @@ exports.process = function(grunt, task, context) {
/**
* Find and resolve specified baseUrl.
*/
function getBaseUrl(baseUrl) {
baseUrl = baseUrl || context.options.requireConfig && context.options.requireConfig.baseUrl || '.';
return grunt.file.expand({
filter: 'isDirectory',
cwd: path.dirname(path.join(process.cwd(), context.outfile))
}, baseUrl)[0] || getBaseUrl('.');
function getBaseUrl() {
var outDir = path.dirname(path.join(process.cwd(), context.outfile));
var requireBaseUrl = context.options.requireConfig && context.options.requireConfig.baseUrl;

if (requireBaseUrl && grunt.file.isDir(outDir, requireBaseUrl)) {
return requireBaseUrl;
} else {
return outDir;
}
}
var baseUrl = getBaseUrl();

Expand Down

0 comments on commit dad367d

Please sign in to comment.