Skip to content

Commit

Permalink
Merge pull request #77 from lukeapage/master
Browse files Browse the repository at this point in the history
Fix path issues
  • Loading branch information
cloudchen committed Apr 7, 2015
2 parents 890766c + f94d9c7 commit 962fb0c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
13 changes: 13 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
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
4 changes: 2 additions & 2 deletions src/templates/jasmine-requirejs.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
<% css.forEach(function(style){ %>
<link rel="stylesheet" type="text/css" href="<%= style %>">
<% }) %>

<% with (scripts) { %>
<% [].concat(vendor).forEach(function(script){ %>
<script src="<%= script %>"></script>
<% }) %>
<% }; %>

<script src="<%= temp %>/require.js"></script>
<script src="<%= temp ? temp + "/" : temp %>require.js"></script>

<% with (scripts) { %>
<% [].concat(jasmine, boot, helpers).forEach(function(script){ %>
Expand Down

0 comments on commit 962fb0c

Please sign in to comment.