Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pulling latest from cloudchen #1

Merged
merged 9 commits into from
May 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@ You'd install `~0.1` version of this template if your test specs are based on Ja
npm install grunt-template-jasmine-requirejs@~0.1 --save-dev
```

## Options

### vendor
Type: `String|Array`

Works same as original. But they are loaded **before** require.js script file

### helpers
Type: `String|Array`

Works same as original. But they are loaded **after** require.js script file

## Template Options

### templateOptions.version
Expand Down Expand Up @@ -235,6 +247,10 @@ var require = {
This automation can help to avoid unexpected dependency order issue

## Change Log
* v0.2.3 Fixed path issues [#77](https://github.com/cloudchen/grunt-template-jasmine-requirejs/pull/77)
* v0.2.2 Fixed regression which casued by [#65](https://github.com/cloudchen/grunt-template-jasmine-requirejs/pull/65)
* v0.2.1 Fixed [#65](https://github.com/cloudchen/grunt-template-jasmine-requirejs/pull/65)
* v0.2.0 Added Jasmine 2 support
* v0.1.10 03.14.14, Fixed [#53](https://github.com/cloudchen/grunt-template-jasmine-requirejs/pull/53), [#52](https://github.com/cloudchen/grunt-template-jasmine-requirejs/issues/52), [#46](https://github.com/cloudchen/grunt-template-jasmine-requirejs/issues/46), [#36](https://github.com/cloudchen/grunt-template-jasmine-requirejs/issues/36) wrong path error when runner outfile is specified at elsewhere
* v0.1.9, 02.04.14, [#57](https://github.com/cloudchen/grunt-template-jasmine-requirejs/issues/57) prevents conflict with `grunt-contrib-jasmine` 0.6.x, added requirejs 2.1.9 & 2.1.10

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "grunt-template-jasmine-requirejs",
"version": "0.2.0",
"version": "0.2.3",
"description": "Requirejs template for grunt-contrib-jasmine",
"main": "src/template-jasmine-requirejs.js",
"scripts": {
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
21 changes: 14 additions & 7 deletions src/templates/jasmine-requirejs.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,20 @@
<link rel="stylesheet" type="text/css" href="<%= style %>">
<% }) %>

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

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

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

<script>
require.onError = function(error) {
var message = error.requireType + ': ';
Expand All @@ -22,12 +35,6 @@
};
</script>

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

<script>
<% if (options.mainRequireConfig) { %>
require.config(<%= serializeRequireConfig(options.mainRequireConfig) %>);
Expand Down