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/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(); 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){ %>