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

Updated code to work with Grunt 1.0. #90

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: node_js
node_js:
- "0.10"
- "4"
before_install:
- npm install -g grunt-cli
script: grunt
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ module.exports = function(grunt) {
helpers: 'test/fixtures/requirejs/spec/*Helper.js',
host: 'http://127.0.0.1:<%= connect.test.port %>/',
template: require('./'),
templateOptions: grunt.util._.extend({version: "vendor/require-2.1.8.js"}, defaultTemplateOptions)
templateOptions: grunt.util._.extend({version: "vendor/require-2.2.0.js"}, defaultTemplateOptions)
}
},
parse_test: {
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ var require = {
This automation can help to avoid unexpected dependency order issue

## Change Log
* v0.3.0 Upgrade to Grunt 1.0
* 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)
Expand Down
22 changes: 13 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "grunt-template-jasmine-requirejs",
"version": "0.2.3",
"version": "0.3.0",
"description": "Requirejs template for grunt-contrib-jasmine",
"main": "src/template-jasmine-requirejs.js",
"scripts": {
Expand Down Expand Up @@ -37,16 +37,20 @@
"Ben Livermore <benjamin.livermore@cengage.com>",
"Ghn <ghugon@gmail.com>",
"E.J. Dyksen <ej@dyksen.net>",
"Brian Ng <bng@prospricing.com>"
"Brian Ng <bng@prospricing.com>",
"Radu Micu <radu.micu@gmail.com>"
],
"license": "BSD",
"license": "BSD-2-Clause",
"devDependencies": {
"grunt-contrib-jshint": "~0.6.4",
"grunt-contrib-watch": "~0.1.4",
"grunt": "~0.4.1",
"grunt-contrib-jasmine": "~0.6",
"grunt-contrib-connect": "~0.2.0",
"grunt-bump": "0.0.13",
"grunt-contrib-jshint": "~1.0.0",
"grunt-contrib-watch": "~1.0.0",
"grunt": "~1.0.1",
"grunt-contrib-jasmine": "~1.0.3",
"grunt-contrib-connect": "~1.0.2",
"grunt-bump": "0.8.0",
"grunt-npm": "0.0.2"
},
"dependencies": {
"lodash": "^4.13.1"
}
}
24 changes: 14 additions & 10 deletions src/template-jasmine-requirejs.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use strict";

var _ = require('lodash');
var template = __dirname + '/templates/jasmine-requirejs.html',
requirejs = {
'2.0.0' : __dirname + '/../vendor/require-2.0.0.js',
Expand All @@ -19,7 +20,8 @@ var template = __dirname + '/templates/jasmine-requirejs.html',
'2.1.7' : __dirname + '/../vendor/require-2.1.7.js',
'2.1.8' : __dirname + '/../vendor/require-2.1.8.js',
'2.1.9' : __dirname + '/../vendor/require-2.1.9.js',
'2.1.10' : __dirname + '/../vendor/require-2.1.10.js'
'2.1.10' : __dirname + '/../vendor/require-2.1.10.js',
'2.2.0' : __dirname + '/../vendor/require-2.2.0.js'
},
path = require('path'),
parse = require('./lib/parse');
Expand Down Expand Up @@ -78,21 +80,21 @@ exports.process = function(grunt, task, context) {
// Extract config from main require config file
if (context.options.requireConfigFile) {
// Remove mainConfigFile from src files
var requireConfigFiles = grunt.util._.flatten([context.options.requireConfigFile]);
var requireConfigFiles = _.flatten([context.options.requireConfigFile]);

var normalizedPaths = grunt.util._.map(requireConfigFiles, function(configFile){
var normalizedPaths = _.map(requireConfigFiles, function(configFile){
return path.normalize(configFile);
});
context.scripts.src = grunt.util._.reject(context.scripts.src, function (script) {
return grunt.util._.contains(normalizedPaths, path.normalize(script));
context.scripts.src = _.reject(context.scripts.src, function (script) {
return _.includes(normalizedPaths, path.normalize(script));
});

var configFromFiles = {};
grunt.util._.map(requireConfigFiles, function (configFile) {
grunt.util._.merge(configFromFiles, parse.findConfig(grunt.file.read(configFile)).config);
_.map(requireConfigFiles, function (configFile) {
_.merge(configFromFiles, parse.findConfig(grunt.file.read(configFile)).config);
});

context.options.requireConfig = grunt.util._.merge(configFromFiles, context.options.requireConfig);
context.options.requireConfig = _.merge(configFromFiles, context.options.requireConfig);
}


Expand All @@ -119,7 +121,7 @@ exports.process = function(grunt, task, context) {
}

// Remove baseUrl and .js from src files
context.scripts.src = grunt.util._.map(context.scripts.src, getRelativeModuleUrl);
context.scripts.src = _.map(context.scripts.src, getRelativeModuleUrl);


// Prepend loaderPlugins to the appropriate files
Expand Down Expand Up @@ -173,5 +175,7 @@ exports.process = function(grunt, task, context) {
context.temp);

var source = grunt.file.read(template);
return grunt.util._.template(source, context);
var tpl = _.template(source);

return tpl(context);
};
Loading