From dad367d05d13f98ca66945be7ffd697ba21c24b3 Mon Sep 17 00:00:00 2001 From: Luke Page Date: Thu, 26 Mar 2015 22:13:06 +0000 Subject: [PATCH 1/2] Implement getBaseUrl in a way that can't recurse and is more likely to succeed --- src/template-jasmine-requirejs.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/template-jasmine-requirejs.js b/src/template-jasmine-requirejs.js index 52d1dcb..3b72f46 100644 --- a/src/template-jasmine-requirejs.js +++ b/src/template-jasmine-requirejs.js @@ -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(); From f94d9c71097c91d6b138ab6e9efcb6909f67e9a5 Mon Sep 17 00:00:00 2001 From: Luke Page Date: Fri, 27 Mar 2015 07:11:25 +0000 Subject: [PATCH 2/2] Fix putting the spec file in the same directory as require.js --- Gruntfile.js | 13 +++++++++++++ src/templates/jasmine-requirejs.html | 4 ++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index d34880f..b8e404c 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -143,6 +143,19 @@ module.exports = function(grunt) { } } }, + 'require-outfile-same-dir': { + src: 'test/fixtures/require-baseurl/src/**/*.js', + options: { + outfile: ".grunt/grunt-contrib-jasmine/_SpecRunner.html", + specs: 'test/fixtures/require-baseurl/spec/**/*Spec.js', + template: require('./'), + templateOptions: { + requireConfig: { + baseUrl: '../../test/fixtures/require-baseurl/src/' + } + } + } + }, }, bump: { options: { diff --git a/src/templates/jasmine-requirejs.html b/src/templates/jasmine-requirejs.html index fecb54b..2f6e9f0 100644 --- a/src/templates/jasmine-requirejs.html +++ b/src/templates/jasmine-requirejs.html @@ -7,14 +7,14 @@ <% css.forEach(function(style){ %> <% }) %> - + <% with (scripts) { %> <% [].concat(vendor).forEach(function(script){ %> <% }) %> <% }; %> - + <% with (scripts) { %> <% [].concat(jasmine, boot, helpers).forEach(function(script){ %>