Skip to content

Commit

Permalink
Merge pull request mgonto#1284 from dreef3/features/umd
Browse files Browse the repository at this point in the history
Features/umd
  • Loading branch information
daviesgeek committed May 10, 2016
2 parents de8a48b + a1f23f1 commit f174316
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 21 deletions.
17 changes: 12 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,33 @@
"dependencies": {
"lodash": ">=1.3.0"
},
"peerDependencies": {
"angular": ">=1.3.12"
},
"devDependencies": {
"angular-mocks": "^1.4.8",
"grunt": "^0.4.5",
"grunt-bower": "*",
"grunt-bower-task": "*",
"grunt-cli": ">= 0.1.7",
"grunt-contrib-concat": "*",
"grunt-contrib-jshint": "*",
"grunt-contrib-uglify": "*",
"grunt-conventional-changelog": "0.0.12",
"grunt-bower": "*",
"grunt-bower-task": "*",
"grunt-karma": "latest",
"grunt-conventional-changelog": "0.0.12",
"grunt-zip": "*",
"karma": "^0.13.19",
"karma-chrome-launcher": "~0.1.2",
"karma-firefox-launcher": "~0.1.3",
"karma-jasmine": "~0.1.5",
"karma-mocha-reporter": "0.2.8",
"karma-phantomjs-launcher": "~0.1.2"
"karma-jasmine": "~0.1.5",
"karma-chrome-launcher": "~0.1.2",
"karma-phantomjs-launcher": "~0.1.2",
"karma-firefox-launcher": "~0.1.3"
},
"scripts": {
"test": "grunt test --verbose"
},
"license": "MIT"
}
}
28 changes: 13 additions & 15 deletions src/restangular.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
(function() {
(function (root, factory) {
// https://github.com/umdjs/umd/blob/master/templates/returnExports.js
if (typeof define === 'function' && define.amd) {
define(['angular', 'lodash'], factory);
} else if (typeof module === 'object' && module.exports) {
module.exports = factory(require('angular'), require('lodash'));
} else {
// No global export, Restangular will register itself as Angular.js module
factory(root._, root.angular);
}
}(this, function (_, angular) {

var restangular = angular.module('restangular', []);

Expand Down Expand Up @@ -1346,17 +1356,5 @@ restangular.provider('Restangular', function() {
return createServiceForConfiguration(globalConfiguration);
}];
});

})();


/**
* This lets you inject the module into angularjs using the commonjs require
* syntax with browserify.
*/
/* jshint ignore:start */
if (typeof module !== 'undefined' && typeof exports !== 'undefined' && module.exports === exports){
var _ = require('lodash');
module.exports = 'restangular';
}
/* jshint ignore:end */
return restangular.name;
}));
2 changes: 1 addition & 1 deletion test/restangularSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ describe("Restangular", function() {
};

CallbackManager.firstErrorInterceptor = function(response) {
expect(response.status).toEqual(404);
expect(Number(response.status)).toEqual(404);
};
CallbackManager.secondErrorInterceptor = function() {};

Expand Down

0 comments on commit f174316

Please sign in to comment.